Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2007

Tip: Looking for answers? Try searching our database.

Merge field+if statement+phone numbers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 12 Mar 2007 18:26 GMT
I have a form file in Word 2000 that merges with an Excel Database.  One of
my fields is a telephone number.

I want to do two things with that telephone number.  One format as (000)
000-0000 and if that Excel telephone field is blank when the merge takes
place, I do not want the telephone number to print at all.  I want the field
to appear blank on the final merged document.  However, if there is a
telephone number in that field then I want the telephone number to print in
the format shown above.

I have tried several versions of an if statement and cannot seem to obtain
the correct statement.

Here is what I have tried:

{IF{MERGEFIELD EmployerPhone}<>"""{MERGEFIELD EmployerPhone}"}

Also tried:

{IF{MERGEFIELD EmployerPhone\#"(000)'-'000'-'0000"}<>"""{MERGEFIELD
EmployerPhone\#"(000)'-'000'-'0000"}"}

and also:

{MERGEFIELD EmployerPhone\#"(000)'-'000'-'0000"}{IF{MERGEFIELD
EmployerPhone\#"(000)'-'000'-'0000"}<>"""{MERGEFIELD
EmployerPhone\#"(000)'-'000'-'0000"}"}

What am I doing wrong.  I have tried merging with files that contain
telephone numbers and are blank.  My results are not consistent.  I can get
it to print in the format I want depending on the above statement variation,
but not consistently blank when the field is blank and not consistently print
the phone number when the filed is not blank.

Help!!!

AJ

Signature

John R.

Peter Jamieson - 12 Mar 2007 19:10 GMT
If you insert

{ MERGEFIELD EmployerPhone }

what results do you see?

Where you have blank in Excel, do you get blank in Word? Or do you sometimes
get 0 or even 0.0 ?

Where you have a phone number such as 5551234567 in Excel, what do you see
in Word?
5551234567 ?
(555)-123-4567 ?
or perhaps even
5551234567.0 ?

If you only ever get blank or 5551234567, then

{ MERGEFIELD EmployerPhone \#"(000)'-'000'-'0000" }

should be enough. If you get 0 where you have blank in Excel, you can try

{ IF { MERGEFIELD EmployerPhone } > 0
"{ MERGEFIELD EmployerPhone \#"(000)'-'000'-'0000" }"
"" }

(You don't have to split it across rows as I have done).

Peter Jamieson

>I have a form file in Word 2000 that merges with an Excel Database.  One of
> my fields is a telephone number.
[quoted text clipped - 38 lines]
>
> AJ
John - 12 Mar 2007 19:23 GMT
Thanks for your help.

In reply to your questions:

Excel field is 5550002417 format

See below also

Signature

John R.

> If you insert
>
> { MERGEFIELD EmployerPhone }  what results do you see?

number unformated just as in Excel - 5550002417

> Where you have blank in Excel, do you get blank in Word? Or do you sometimes
> get 0 or even 0.0 ?

Actually I get a strange number 000-000-5245

> Where you have a phone number such as 5551234567 in Excel, what do you see
> in Word?
[quoted text clipped - 12 lines]
> "{ MERGEFIELD EmployerPhone \#"(000)'-'000'-'0000" }"
> "" }

I can easily get the number to format with the correct () and dashes using
just the switch to do so and the MERGEFIELD Employer Phone.  However, trying
to add in a statement that indicates that if the Excel field is blank then
print nothing in the merge final document and if the Excel field has a number
5552140000 then print that number but formated as (555)-214-0000.

Thank you,
AJ

> (You don't have to split it across rows as I have done).
>
[quoted text clipped - 42 lines]
> >
> > AJ
Peter Jamieson - 12 Mar 2007 20:15 GMT
If you're getting

000-000-5245

when you should be getting <blank> then nothing you do with formatting
switches in Word is likely to work.

If you're connecting with DDE (the default) you may be seeing the type of
problem described in the following article:

http://support.microsoft.com/kb/204542/en-us

I can't check with Word/Excel 2000 right now, but if possible I would
probably go into each Excel cell in your EmployerPhone column that should be
<blank> and
a. use Edit|Clear|All to ensure it's blank
b. consider changing the cell format (Format|Cells|Number) to General or
Text.

I'm not sure that will make any difference but you could try it with a
couple of the offending cells and see what happens.

If you just have data and no cell formulas etc., you could also consider
recreating your sheet by exporting as .csv and re-importing.

Peter Jamieson
> Thanks for your help.
>
[quoted text clipped - 97 lines]
>> >
>> > AJ
John - 12 Mar 2007 20:29 GMT
Thank you Peter.  You have been a great help.  

My problem was partly due to my error.  I had assigned another person to
update the Excel telephone number fields to be 0000000000 instead of
000-000-0000.  I just happened to be using the particular field as my test
field for this project that had not been correctly updated.  

Anyway, the statement that finally worked correctly for me is the following:

{MERGEFIELD EmployerPhone\#"(000)'-'000'-'0000}{IF{MERGEFIELD
EmployerPhone}<>""""}.

Sorry to have caused you so much work.  I am just thankful that it finally
works.

Take care.
AJ
Signature

John R.

> If you're getting
>
[quoted text clipped - 123 lines]
> >> >
> >> > AJ
macropod - 12 Mar 2007 21:36 GMT
Hi John,

If your Excel fields are all 5550002417 format, you don't need an IF test. You could use:
{MERGEFIELD EmployerPhone \# "(000)'-'000'-'0000;;"}
This will suppress the display if there is no phone number.

Cheers

Signature

macropod
[MVP - Microsoft Word]
-------------------------

> Thank you Peter.  You have been a great help.  
>
[quoted text clipped - 141 lines]
>> >> >
>> >> > AJ
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.