J
jb914
I have a VBA addin for word that will fill in multiple bookmarks in a
document. So, if i have bookmarks in a document bkName, bkName1, bkName2,
ect.......throughout the document the program will fill in the name in the
right spot. it simply looks for a new
My users are novices. i am trying to build them a toolbar to simplify the
process.
i have the toolbar built which includes a bunch of buttons using code like:
Sub bkName()
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="bkName"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub
I know the program uses the following code to loop thru filling in the
bookmarks
Private Sub SetBookmarkText(doc As Document, ByVal Name As String, ByVal
Value As String)
On Error Resume Next
With doc
.Bookmarks(Name).Range.Text = Value
Dim i As Integer
i = 1
Do While .Bookmarks.Exists(Name & CStr(i))
.Bookmarks(Name & CStr(i)).Range.Text = Value
i = i + 1
Loop
End With
End Sub
How would i modify the bookmark creation code to check for an existing
bookmark and LOOP thru to create them? So, if bkName is already in the
document it will insert a bookmark bkName1 and if bkName1 is already in it
will do bkName2
any direction would be appreciated.
thanks
JB
document. So, if i have bookmarks in a document bkName, bkName1, bkName2,
ect.......throughout the document the program will fill in the name in the
right spot. it simply looks for a new
My users are novices. i am trying to build them a toolbar to simplify the
process.
i have the toolbar built which includes a bunch of buttons using code like:
Sub bkName()
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="bkName"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
End Sub
I know the program uses the following code to loop thru filling in the
bookmarks
Private Sub SetBookmarkText(doc As Document, ByVal Name As String, ByVal
Value As String)
On Error Resume Next
With doc
.Bookmarks(Name).Range.Text = Value
Dim i As Integer
i = 1
Do While .Bookmarks.Exists(Name & CStr(i))
.Bookmarks(Name & CStr(i)).Range.Text = Value
i = i + 1
Loop
End With
End Sub
How would i modify the bookmark creation code to check for an existing
bookmark and LOOP thru to create them? So, if bkName is already in the
document it will insert a bookmark bkName1 and if bkName1 is already in it
will do bkName2
any direction would be appreciated.
thanks
JB