Sarahmueller
New Member
- Joined
- May 17, 2020
- Messages
- 24
- Office Version
- 365
- 2016
- Platform
- Windows
Hello,
I hope you all are well.
I want to insert text from an excel-cell (B16) into a word document. The text should be inserted after the respective bookmark ("B1").
I have written the following code:
Sadly, the macro inserts the the at the bookmark, rather than after the bookmark B1.
Do you have an idea how I can fix my code to insert the text after the bookmark?
Best regards and many thanks in advance
Sarah
I hope you all are well.
I want to insert text from an excel-cell (B16) into a word document. The text should be inserted after the respective bookmark ("B1").
I have written the following code:
VBA Code:
Sub InsertAfterBookmark()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets(1)
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open ("path of word document”)
With objWord.ActiveDocument
.Bookmarks("B1").Range.Text = ws.Range("B16").Value
End With
Set objWord = Nothing
End Sub
Sadly, the macro inserts the the at the bookmark, rather than after the bookmark B1.
Do you have an idea how I can fix my code to insert the text after the bookmark?
Best regards and many thanks in advance
Sarah