Hello all,
I'm new to the whole VBA in word, and am struggling to resolve this issue!!!
What I am trying to achieve is to have a doc with various bookmarks, when a script is run, vba systematically goes through all bookmarks, requests user input via an inputbox, and then replaces the text with the user determined text.
This is what I have so far;
Code:
Sub UpdateBookmarks()
Dim bmInput As String
For Each bm In ActiveDocument.Bookmarks
bmInput = InputBox("Please enter " & bm.Name)
UpdateBM ActiveDocument, bm.Name, bmInput
Next
End Sub
Sub UpdateBM(ByRef bmDoc As Document, bmName As String, bmContent As String)
Dim bmRng As Word.Range
Set bmRng = bmDoc.Bookmarks(bmName).Range
bmRng.Text = bmContent
End Sub
However, when I run the code, it inserts the user input at the beginning of the text already present in the bookmark, rather than replacing it.
Please can anyone help??
Many thanks all