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 / December 2003

Tip: Looking for answers? Try searching our database.

Multiple bookmarks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 02 Dec 2003 09:06 GMT
Hi,
I'm using vb.net to merge data to a Word 2000 document.
The document is set up as a letter and I've inserted
bookmarks to merge the data. How do I have multiple
bookmarks to merge the same data. ie I have bookmarks for
client name and address at the top of the document, but I
also want client name further down the letter. I don't
want to have ClientName1, ClientName2 etc. Any ideas?
Peter Jamieson - 02 Dec 2003 11:50 GMT
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
insert the data. The simplest change to that approach would probably be to
insert the data, then bookmark the newly inserted data. Then, suppose you
had a bookmark called ClientName, you can use { REF ClientName } fields to
insert further copies of the bookmarked information elsewhere in your
document - you may need to .Execute all the fields in the appropriate range.

Alternatively if your data is always just plain text, you could consider
using Word document variables to contain the texts you want to use, and use
{ DOCVARIABLE } fields to insert the texts. I think that approach is
reasonably safe in Word 2000 - in earlier versions DOCVARIABLE fields in
headers could crash Word.

--
Peter Jamieson - Word MVP

> Hi,
> I'm using vb.net to merge data to a Word 2000 document.
[quoted text clipped - 4 lines]
> also want client name further down the letter. I don't
> want to have ClientName1, ClientName2 etc. Any ideas?
Peter Jamieson - 02 Dec 2003 12:10 GMT
.Execute should be .Update

Doh!

--
Peter Jamieson - Word MVP

> 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?
John Pearson - 03 Dec 2003 09:53 GMT
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 :-)
 
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.