Kaiser TCF
New Member
- Joined
- Jul 20, 2021
- Messages
- 6
- Office Version
- 2019
- Platform
- Windows
Hello gents,
I have an embedded word object inside my excel sheet and would like to copy a range of excel data as a table inside the word.
note that I already wrote a code that opens the word document and manipulates and copy data from excel to it ( NOT important: the code I wrote can paste excel data to word book mark and content control)
anyhow, I tried testing a similar code that copies the data from excel to a word document (not embedded) and it seems to work. but I just can't seem to do it in an embedded word document. see the code below. do I need to add a piece of code to fix this or do I need to start from scratch? (the red code is what gives the error)
I have an embedded word object inside my excel sheet and would like to copy a range of excel data as a table inside the word.
note that I already wrote a code that opens the word document and manipulates and copy data from excel to it ( NOT important: the code I wrote can paste excel data to word book mark and content control)
anyhow, I tried testing a similar code that copies the data from excel to a word document (not embedded) and it seems to work. but I just can't seem to do it in an embedded word document. see the code below. do I need to add a piece of code to fix this or do I need to start from scratch? (the red code is what gives the error)
Dim WrdApp As Word.Application
Dim WrdDoc As Word.Document
Dim sh As Shape
Dim objWord As Object
Dim objOLE As OLEObject
Dim wSystem As Worksheet
Dim cell As Range
Dim FileName As String
Set wSystem = Worksheets("sheet1")
Set sh = wSystem.Shapes("Object 3")
sh.OLEFormat.Activate
Set objOLE = sh.OLEFormat.Object
Set objWord = objOLE.Object
Workbooks("Table.xlsm").Worksheets("sheet1").Range("G2:J7").Copy
objWord.Selection.PasteExcelTable False, False, False