1 Attachment(s)
[RESOLVED] Bookmarks In Word Are Disappearing
I have a word document that I'm using as a template to prepare a letter. This template has several bookmarks which will be populated from a VB6 screen.
The problem that I'm having is that several of the bookmarks are disappearing when I open the finished product. Example:
The heading of the document contains todays date, the name of the letter receiptant, his/her title, company name, street address and city/state.
All of these are bookmarks.
It is layed out thus:
[Current_Date]
[Contact]
[Title]
[Provider]
[Street_Address]
[City]
However, when I run it, it looks like this:
[Current_Date]
[Title][City]
:confused: What the heck is going on?
As a picture is worth a thousands words, I've extracted the part of my project that creates this letter, and pasted it into a test project, which I've zipped and attached. The word template is also included. To get a visual on what is happening, just download the attachment, unzip it, run it, and click Command1.
Signed:
Baffled In Sterling Heights
Re: Bookmarks In Word Are Disappearing
This is not resolved in terms of knowing what caused the problem, but I have solved the issue.
I whacked all of my templates, and recreated them from scratch, and now my bookmarks are working just fine.
Re: [RESOLVED] Bookmarks In Word Are Disappearing
You shouldnt add text to a bookmark this way...
VB Code:
.ActiveDocument.Bookmarks("contact1").Select
.Selection.Text = (cboContacts.Text)
You can blow away the actual bookmark by using the selection of it.
There is a Text property that you can use for more reliability.
VB Code:
.ActiveDocument.Bookmarks("contact1").Range.Text = cboContacts.Text
Re: [RESOLVED] Bookmarks In Word Are Disappearing
Also, in case you want to append to the bookmark then use the InsertAfter method.
VB Code:
ActiveDocument.Bookmarks("contact1").Range.InsertAfter = cboContacts.Text
Re: [RESOLVED] Bookmarks In Word Are Disappearing
Quote:
Originally Posted by RobDog888
Also, in case you want to append to the bookmark then use the InsertAfter method.
VB Code:
ActiveDocument.Bookmarks("contact1").Range.InsertAfter = cboContacts.Text
Thanks Rob....I didn't know about these two. :thumb: