Apr 28th, 2006, 08:50 AM
#1
[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]
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
Attached Files
Last edited by Hack; Apr 28th, 2006 at 09:25 AM .
May 1st, 2006, 11:53 AM
#2
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.
May 1st, 2006, 12:26 PM
#3
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
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 1st, 2006, 04:03 PM
#4
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
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
May 2nd, 2006, 07:28 AM
#5
Re: [RESOLVED] Bookmarks In Word Are Disappearing
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.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width