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

Tip: Looking for answers? Try searching our database.

Inserting a Document via an IF Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rtrsr - 16 Feb 2004 23:54 GMT
I'm trying to write an IF statement that will insert a document at the end of the currently active document when an IF test returns a TRUE.

In rudimentary programming terms, this is all I'm trying to do -- using a variable called "Waiver" and a document named c:\My Documents\Waiver.doc.

    IF Waiver="Y" Append c:\My Documents\Waiver.doc ELSE DoNothing

There doesn't seem to be a field code that accomplishes (or even approximates) this.  I've successfully written a MACROBUTTON routine that will append c:\My Documents\Waiver.doc  when the operator clicks on it -- but I'd really like this to get launched simply in response to a TRUE result in an IF statement.

This has GOT to be super-simple.  So what am I missing here?

Rick
Peter Jamieson - 17 Feb 2004 06:25 GMT
If your variable is a bookmark  then you would typically need a nested field
such as

{ IF "{ REF waiver }" = "Y" "{ INCLUDETEXT "c:\\My Documents\\Waiver.doc }"
"" }

(where all the {} are the special field code braces you can insert using
Ctrl-F9).

If waiver is a merge field, the equivalent would be

{ IF "{ MERGEFIELD waiver }" = "Y" "{ INCLUDETEXT "c:\\My
Documents\\Waiver.doc" }" "" }

However, precisely when the document would be appended would depend on what
you are doing. If the fields are ina standalone document. the fields would
have to be refreshed (select, then F9) for the document to reflect the
current value of Waiver. In a mailmerge, it should all happen automatically,
but if it does not you might need to do something more like

{ IF "{ MERGEFIELD waiver }" = "Y" "{ SET docname "waiver" }" "{ SET docname
"nowaiver" }"
}{ INCLUDETEXT "c:\\My Documents\\{ REF docname }.doc" }

You will also probably run into difficulties if there are any formatting
clashes (e.g. you use the same style names in waiver.doc as your main
document, but with different settings).

--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

I'm trying to write an IF statement that will insert a document at the end
of the currently active document when an IF test returns a TRUE.

In rudimentary programming terms, this is all I'm trying to do -- using a
variable called "Waiver" and a document named c:\My Documents\Waiver.doc.

    IF Waiver="Y" Append c:\My Documents\Waiver.doc ELSE DoNothing

There doesn't seem to be a field code that accomplishes (or even
approximates) this.  I've successfully written a MACROBUTTON routine that
will append c:\My Documents\Waiver.doc  when the operator clicks on it --
but I'd really like this to get launched simply in response to a TRUE result
in an IF statement.

This has GOT to be super-simple.  So what am I missing here?

Rick
rtrsr - 19 Feb 2004 02:11 GMT
Peter,

Once again, your help has been generous, precise and timely.  INCLUDETEXT
worked fine -- first time!  THANKS ever so much!!  IOU1

Rick

> If your variable is a bookmark  then you would typically need a nested field
> such as
[quoted text clipped - 45 lines]
>
> Rick
 
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.