aellington287
New Member
- Joined
- Mar 7, 2016
- Messages
- 7
I am somewhat new to VBA, I have created a userform that will open a word document and update several lines of text within the document before saving and closing it. I know that it is possible to insert text at a bookmark, but I do not currently have the understanding to do this. My code is as follows:
What line of code would I use and where would I put it if I were wanting to insert "I love excel and VBA" followed by the contents of cell A1, at the bookmark labeled "txtbx1"? Any help would be appreciated. Thanks!
Code:
Private Sub Generate_Click()
Dim wdapp As Object
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
wdapp.ChangeFileOpenDirectory "V:\PI\QI\MDB\"
wdapp.documents.Open Filename:="DATA- -PSS.docx"
wdapp.ActiveDocument.Close savechanges:=True
wdapp.Quit
Set wdapp = Nothing
Unload Me
End Sub
What line of code would I use and where would I put it if I were wanting to insert "I love excel and VBA" followed by the contents of cell A1, at the bookmark labeled "txtbx1"? Any help would be appreciated. Thanks!