Hi all,
I am running some code which copies a table from Excel to Word inside a bookmark I wish to retain the bookmark for later use. Below is the code.
The following is the general flow:
Opens Word
Opens a Document Template
Copies a ListObject Table
Finds the bookmark in Word
Pastes the Table
Sub UpdateBookmarkContents()
'set word application dimensions
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("word.application")
'Open the relevent Document
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Add(Template:="\\svr\documents\Word\Template.dotx", NewTemplate:=False, DocumentType:=0)
'Clear Clipboard
Application.CutCopyMode = False
' Create reference to QuoteTableW and copy
Dim ExcLisObjq As ListObject
Set ExcLisObjq = Sheets("Quote Tables").ListObjects("QuoteTableW")
ExcLisObjq.Range.Copy
'Paste Object to Location
wdDoc.Bookmarks("RNBMQuoteTableW").Range.PasteExcelTable _
LinkedToExcel:=False, _
WordFormatting:=False, _
RTF:=True
'Clear Clipboard
Application.CutCopyMode = False
End Sub
I am running some code which copies a table from Excel to Word inside a bookmark I wish to retain the bookmark for later use. Below is the code.
The following is the general flow:
Opens Word
Opens a Document Template
Copies a ListObject Table
Finds the bookmark in Word
Pastes the Table
Sub UpdateBookmarkContents()
'set word application dimensions
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("word.application")
'Open the relevent Document
wdApp.Visible = True
Set wdDoc = wdApp.Documents.Add(Template:="\\svr\documents\Word\Template.dotx", NewTemplate:=False, DocumentType:=0)
'Clear Clipboard
Application.CutCopyMode = False
' Create reference to QuoteTableW and copy
Dim ExcLisObjq As ListObject
Set ExcLisObjq = Sheets("Quote Tables").ListObjects("QuoteTableW")
ExcLisObjq.Range.Copy
'Paste Object to Location
wdDoc.Bookmarks("RNBMQuoteTableW").Range.PasteExcelTable _
LinkedToExcel:=False, _
WordFormatting:=False, _
RTF:=True
'Clear Clipboard
Application.CutCopyMode = False
End Sub