Still plugging away at this one. At the moment I'm getting a 'Compile error: Variable not defined' here, when pressing the first button (haven't even bothered with the second button yet) :-
'Create reference to object we want to copy
Set objWorksheet = ActiveWorkbook.Worksheets("Markers")
This is the code that I have for both buttons :-
' Add Markers Detail
Private Sub AggrievedBut_Click()
'Using Early Binding
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
Dim WrdTbl As Word.Table
Application.ScreenUpdating = False
'Create reference to object we want to copy
Set objWorksheet = ActiveWorkbook.Worksheets("Markers")
' Copying the content from Excel worksheet named Markers
ThisWorkbook.Worksheets("Markers").Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select.Copy
'Pasting into the document within TextBox3
TextBox3(1).Range.Selection.PasteExcelTable _
LinkedToExcel:=False, WordFormatting:=True, RTF:=False
'Emptying the Clipboard
CutCopyMode = False
End Sub
' Add Person Detail
Private Sub PersonBut_Click()
'Using Early Binding
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
Dim WrdTbl As Word.Table
Application.ScreenUpdating = False
'Create reference to object we want to copy
Set objWorksheet = ActiveWorkbook.Worksheets("Person")
' Copying the content from Excel worksheet named Person
ThisWorkbook.Worksheets("Person").Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select.Copy
'Pasting into the document within TextBox3
TextBox3(1).Range.Selection.PasteExcelTable _
LinkedToExcel:=False, WordFormatting:=True, RTF:=False
'Emptying the Clipboard
CutCopyMode = False
End Sub
I can forsee that even if I could get one of the buttons to work, then clicking on the other to add another table will overwrite the previous one in my Word document's TextBox3.