+ Reply to Thread
Results 1 to 2 of 2

Thread: replacing Enclosing bookmark with another Enclosing bookmark not Placeholder bookmark

  1. #1
    Registered User
    Join Date
    08-16-2011
    Location
    Oslo
    MS-Off Ver
    Excel 2007
    Posts
    7

    replacing Enclosing bookmark with another Enclosing bookmark not Placeholder bookmark

    Hi there,

    in short, I want to insert some text into a bookmark, (called CompanyName1 which is an Enclosing bookmark) and after this has been done I would like to set the inserted text as another Enclosing bookmark of the same name, (CompanyName1) so that this template can be used again. The problem with the below code is when it re-inserts the bookmark, it inserts a Placeholder bookmark and appends itself to the begginning of the previously inserted word.

    I need to create an Enlosing bookmark around the newly inserted word.


    Private Sub btnAddData_Click()
    
    
                Dim CompanyName As String
    
                CompanyName = txtbxCompanyName.Text
    
                Dim RangeCompanyName1 As Range
                'Identify current Bookmark range and insert text
                
                Set RangeCompanyName1 = ActiveDocument.Bookmarks("CompanyName1").Range
                
                ActiveDocument.Bookmarks("CompanyName1").Range.Text = txtbxCompanyName.Value
    
                
                ActiveDocument.Bookmarks.Add "CompanyName1", RangeCompanyName1
                
                 End Sub
    Thank you for any help.

  2. #2
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: replacing Enclosing bookmark with another Enclosing bookmark not Placeholder book

    Use documentvariables instead.

     
    Sub snb()
      activedocument.variables("company")="MycompanyName PLC"
      activedocument.fields.update
    End sub
    You can place the documentvariable-field as often as you like, wherever you like, formatted as you like into the document. Changing the content of the variable will be in effect anywhere in the document.

    Inserting docvariable-fields into the docuemnt: Menubar/insert/fields/docvariable



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0