I have tried finding a solution to this but with little succes. I was succesfully able to update my Word Document but only once. I checked the word document and the bookmark has disappeared so doesn't work the second time unless I add a bookmark again in the Word Document. Please find the code below and let me know what may be done to achieve the required. Thanks!!
Sub Rectangle2_Click()
Dim tbl As Excel.Range
Dim WordApp As Word.Application
Dim myDoc As Word.Document
Dim WordTable As Word.Table
'Optimize Code
Application.ScreenUpdating = False
Application.EnableEvents = False
'Copy Range from Excel
Set tbl = ThisWorkbook.Worksheets("Sheet1").Range("C6:M10")
'Create an Instance of MS Word
On Error Resume Next
'Is MS Word already opened?
Set WordApp = GetObject(class:="Word.Application")
'Clear the error between errors
Err.Clear
'If MS Word is not already open then open MS Word
If WordApp Is Nothing Then Set WordApp = CreateObject(class:="Word.Application")
'Handle if the Word Application is not found
If Err.Number = 429 Then
MsgBox "Microsoft Word could not be found, aborting."
GoTo EndRoutine
End If
On Error GoTo 0
'Make MS Word Visible and Active
WordApp.Visible = True
WordApp.Activate
'Open the Report
Set myDoc = WordApp.Documents.Open("C:\Users\Test.docx")
'Copy Excel Table Range
tbl.Copy
'Delete old Table in MS Word & Paste New Table into MS Word
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
If bkm.Name = bkmname Then
If bkm.Range.Information(wdWithInTable) = True Then
bkm.Range.Expand (wdCell)
bkm.Range.Cells.Delete
End If
End If
Next bkm
myDoc.Bookmarks(1).Range.PasteExcelTable _
LinkedToExcel:=False, _
WordFormatting:=False, _
RTF:=False
'Autofit Table so it fits inside Word Document
Set WordTable = myDoc.Tables(1)
WordTable.AutoFitBehavior (wdAutoFitWindow)
EndRoutine:
'Optimize Code
Application.ScreenUpdating = True
Application.EnableEvents = True
'Clear The Clipboard
Application.CutCopyMode = False
'Closing the MS Word
ActiveDocument.Close SaveChanges:=wdSaveChanges
End Sub
NOTE : I am purely using VBA for the first time but have pieced this up from different sources with hopefully the right logic in mind