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.
Thank you for any help.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
Use documentvariables instead.
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.Sub snb() activedocument.variables("company")="MycompanyName PLC" activedocument.fields.update End sub
Inserting docvariable-fields into the docuemnt: Menubar/insert/fields/docvariable
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks