charming
asked on
Macro to Prompt User for Entry of Text into Word Bookmarks
I have a Word Document with 2 Bookmarks Named Bookmark_Header and Bookmark_Footer, which have been placed into my Word document in their respective Header/Footer Locations.
What I need is a macro that prompts the user for Text and places that Text in both Bookmarks
i.e.Document Opens
Input Box says
Please Enter Filename
User types in New Business Data (or whatever they choose)
Result
the Bookmark_Header displays New Business Data
and the Bookmark_Footer also displays New Business Data
Also, can we clear out any Text to the right of the bookmark that already exists before typing thr File Name
What is the VBA Code for a Macro that I can use in the Document Open event to do this? Thanks
What I need is a macro that prompts the user for Text and places that Text in both Bookmarks
i.e.Document Opens
Input Box says
Please Enter Filename
User types in New Business Data (or whatever they choose)
Result
the Bookmark_Header displays New Business Data
and the Bookmark_Footer also displays New Business Data
Also, can we clear out any Text to the right of the bookmark that already exists before typing thr File Name
What is the VBA Code for a Macro that I can use in the Document Open event to do this? Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Runtime error 5678 Word cannot find the requested bookmark.
Breaks here Selection.GoTo What:=wdGoToBookmark, Name:="Bookmark_Header"
Any ideas? Thanks
Sub EnterData()
Dim strData As String
strData = InputBox("Enter data?")
Selection.GoTo What:=wdGoToBookmark, Name:="Bookmark_Header"
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertAfter strData
ActiveDocument.Bookmarks.A
End Sub