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 / August 2004

Tip: Looking for answers? Try searching our database.

If then else

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cara - 27 Aug 2004 21:16 GMT
Hi~

Is there a way to include more than one merge field in an
if then else statement?  What I'd like to do is if my
merge field equals a certain value, then I want to insert
the data from another merge field, not just insert plain
text.

I'm using Office XP Professional.

Thanks for any help/suggestions!!
Cara
macropod - 27 Aug 2004 23:22 GMT
Hi Cara,

Yes, the syntax might go something like:

{IF{MERGEFIELD Data1}= "" "{MERGEFIELD Data1}" "{MERGEFIELD Data2}"}
or
{IF{MERGEFIELD Data1}= "Test Condition" "{MERGEFIELD Data1}" "{MERGEFIELD
Data2}"}
or
{IF{MERGEFIELD Data1}= "{MERGEFIELD Data2}" "{MERGEFIELD Data3}"
"{MERGEFIELD Data4}"}
etc

Cheers

> Hi~
>
[quoted text clipped - 8 lines]
> Thanks for any help/suggestions!!
> Cara
Cara - 28 Aug 2004 01:20 GMT
Thanks!  It worked great, until I tried to update my "test
condition".

It seems to work only in the first record of my database,
regardless of what variable I put in. (Although when I
merge to a new document, it merges the entire database,
but still no connection to the specified begin date.  
Also, when I merge to a new document, it brings up a new
page for each record.  I want them all to remain on the
same page, in the individual cells.)

Let me explain what I am trying to use this for, maybe
that will help.

I have two columns "Begin date" and "Info".  The begin
date is listed in the date format 9/1/04, 9/2/04 etc.
The "Info" is a listing of program information such as
name, location, staffing, etc.

I am trying to merge these into a Word Document formatted
as a Calendar (template downloaded from MS Online).  My
idea is to put a custom "if, then, else" sentence in each
cell of the calendar, with a specific date variable. E.G.
On Sep 1, the code would read:  {IF
{MERGEFIELD "Begin_date"}
= "9/1/04" "{MERGEFIELD "Begin_date"}" "{MERGEFIELD "Info"}
"}
My theory was that this should only pull the records that
have a begin date of 9/1/04, and ignore all the others.
Then on 9/2/04, I would replace the date with 9/2/04, and
it would only pull that day, etc.

I think I am just putting something in wrong. Any other
suggestions would be greatly appreciated.  Thanks so much!!
Cara
>-----Original Message-----
>Hi Cara,
[quoted text clipped - 31 lines]
>
>.
Doug Robbins - 28 Aug 2004 02:00 GMT
If there is only one record for each date, you probably don't need If then
Else at all.  Setting the calendar up as a label type mailmerge document
should cause the data for each date to go into a separate cell.  The data
will however need to be sorted into date order.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Thanks!  It worked great, until I tried to update my "test
> condition".
[quoted text clipped - 75 lines]
>>
>>.
Cara - 30 Aug 2004 17:00 GMT
Hi~

Thanks so much for all of your help!  Unfortunately, there
might be more than one record for each date, and possibly
none at all. E.G. There might be one program on 9/1/04,
none on 9/2/04 and 9/3/04, then four programs on 9/4/04.  
That's why I'm trying to figure out the If then Else
sentence.  As a last resort, I can just copy and paste my
data out of Excel into my Word calendar, but since the
information will be updated frequently, I was hoping I
could figure out the merge.

If I could just ask for the If then else clarification one
more time, maybe I can get somewhere.  I'm also trying to
read up on merge fields on the mvps.org website, to try to
make some sense of the merge sentence.  I have been given
a deadline of September 1st to have the calendar up and
running, so I'm getting ready to cut and paste pretty soon.

Again, thanks everyone for their help.  Any suggestions
are much appreciated!!

Cara :)

>-----Original Message-----
>If there is only one record for each date, you probably don't need If then
[quoted text clipped - 27 lines]
>> On Sep 1, the code would read:  {IF
>> {MERGEFIELD "Begin_date"}

= "9/1/04" "{MERGEFIELD "Begin_date"}" "{MERGEFIELD "Info"}
>> "}
>> My theory was that this should only pull the records that
[quoted text clipped - 51 lines]
>
>.
Doug Robbins - 31 Aug 2004 01:49 GMT
Starting with a Catalog type mailmerge, the following could probably be
modified to do what you want:  Depending on your prowess with VBA, copying
and pasting might be easier.

' Macro by Doug Robbins to create multiple items per condition in separate
tables from a directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range

Dim data As Range, stab As Table, ttab As Table

Dim i As Long, j As Long, k As Long, n As Long

Set source = ActiveDocument

Set target = Documents.Add

Set stab = source.Tables(1)

k = stab.Columns.Count

Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)

Set scat = stab.Cell(1, 1).Range

scat.End = scat.End - 1

ttab.Cell(1, 1).Range = scat

j = ttab.Rows.Count

For i = 1 To stab.Rows.Count

   Set tcat = ttab.Cell(j, 1).Range

   tcat.End = tcat.End - 1

   Set scat = stab.Cell(i, 1).Range

   scat.End = scat.End - 1

   If scat <> tcat Then

       ttab.Rows.Add

       j = ttab.Rows.Count

       ttab.Cell(j, 1).Range = scat

       ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True

       ttab.Rows.Add

       ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False

       For n = 2 To k

           Set data = stab.Cell(i, n).Range

           data.End = data.End - 1

           ttab.Cell(ttab.Rows.Count, n - 1).Range = data

       Next n

   Else

       ttab.Rows.Add

       For n = 2 To k

           Set data = stab.Cell(i, n).Range

           data.End = data.End - 1

           ttab.Cell(ttab.Rows.Count, n - 1).Range = data

       Next n

   End If

Next i

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hi~
>
[quoted text clipped - 131 lines]
>>
>>.
macropod - 31 Aug 2004 10:22 GMT
Hi Cara,

Depending on what you're doing, perhaps you don't need a mailmerge at all.
Have you tried copying data from the Excel sheet and pasting it into Word
using Edit|Paste Special, and choosing the 'paste link' option? Unless you
need to have different calendars for different people, this should be
sufficient, and will result in the Word document updating whenever the Excel
file is updated.

Cheers

> Hi~
>
[quoted text clipped - 131 lines]
> >
> >.

Rate this thread:






 
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.