Inserting a Document via an IF Statement

R

rtrsr

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
 
P

Peter Jamieson

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
 
R

rtrsr

Peter,

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

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top