Results 1 to 5 of 5

Thread: [RESOLVED] Bookmarks In Word Are Disappearing

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Resolved [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 Attached Files
    Last edited by Hack; Apr 28th, 2006 at 09:25 AM.

  2. #2

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Bookmarks In Word Are Disappearing

    You shouldnt add text to a bookmark this way...
    VB Code:
    1. .ActiveDocument.Bookmarks("contact1").Select
    2.    .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:
    1. .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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Bookmarks In Word Are Disappearing

    Also, in case you want to append to the bookmark then use the InsertAfter method.
    VB Code:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. 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
  •  



Click Here to Expand Forum to Full Width