> It depends on exactly what you are doing. My guess is that you are just
> using the bookmarks as placeholders, and the bookmarks are lost when you
[quoted text clipped - 21 lines]
> > also want client name further down the letter. I don't
> > want to have ClientName1, ClientName2 etc. Any ideas?
Thanks for the help Peter. You are right, I am using the
bookmarks as placeholders and this works fine. A simple
objWordDoc.Bookmarks.Item("CompanyName").Range.InsertAfter
(txtCompanyName.Text)
inserts the company name in the bookmark "CompanyName".
However, if I put a field code further down the document
such as {ref CompanyName} I get a blank. I can only toggle
between blank and the field code! Maybe it's because I'm
not doing an .Update - to what does this method belong?
>-----Original Message-----
>..Execute should be .Update
[quoted text clipped - 33 lines]
>
>.
John Pearson - 03 Dec 2003 10:20 GMT
ActiveDocument.Fields.Update()
If this is what you mean, it has not had an effect. Still
showing the field code and not the CompanyName!!!
>-----Original Message-----
>Thanks for the help Peter. You are right, I am using the
[quoted text clipped - 67 lines]
>>
>.
Cindy M -WordMVP- - 03 Dec 2003 18:16 GMT
Hi John,
No, the problem is that the bookmark doesn't CONTAIN the
string you're inserting. It's more like an insertion point: I
You need this kind of bookmark: [string]
And in order to get it, you need to work with the Range
object a bit differently. Roughly:
bkm = doc.Bookmarks.Item("CompanyName")
If doc.Bookmarks.Exists("CompanyName") Then
rng = bkm.Range
rng.Text = txtcompanyName.Text
doc.Bookmarks.Add(Name:="CompanyName"), Range:=rng)
End If
> Thanks for the help Peter. You are right, I am using the
> bookmarks as placeholders and this works fine. A simple
[quoted text clipped - 6 lines]
> between blank and the field code! Maybe it's because I'm
> not doing an .Update - to what does this method belong?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word
This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)