using INCLUDETEXT?

B

BrendaLL

Hello. I'm very new at Word programming. I am a .NET programmer trying to
figure some stuff out in Word. Here is basically what I want to do:

I have a bookmark in a doc and I want to do something like this:

If [bookmark1] = "hello" Then
INCLUDETEXT = "It was found"
Else
INCLUDETEXT = "Not found"
End If

I know that is NOT how it is coded, but I need help getting started on this.

Thanks!
 
C

Charles Kenyon

Look into IF fields.
{ IF bookmark1="hello" "It was found" "Not found" }
The IncludeText field pulls text from another file.

Note, you cannot just type the braces {}. You can use Ctrl-F9 to insert them
or use Insert > Field...
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
G

Graham Mayor

You can do this with an IF field in the document.

{IF {REF Bookmark1 \*lower} = "hello" "It was found" "Not found"}

The \*lower switch is optional but caters for such entries as "Hello" and
"HELLO" as well as "hello"
In a REF field the REF bit is also optional, but I like to include it for
the sake of clarity.
thus
{IF {Bookmark1} = "hello" "It was found" "Not found"}
would probably suffice.

Note the {} indicate fields and are inserted with CTRL+F9.

If you want to use large insertions then you can use INCLUDETEXT fields or
AUTOTEXT fields eg

{IF {REF Bookmark1 \*lower} = "hello" "{INCLUDETEXT
"C:\\path\\filename.doc"}" "{AUTOTEXT "autotextname"}"}

You may find http://www.gmayor.com/formatting_word_fields.htm useful.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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