clevercloggs
New Member
- Joined
- Jun 29, 2018
- Messages
- 4
Hi,
I am creating a report creation Macro to Export data to word but would also like to automatically embed the Excel file that the Macro is running from into the word template.
Hi have been experimenting with this code but not sure if it is the correct way to do it.
I am creating a report creation Macro to Export data to word but would also like to automatically embed the Excel file that the Macro is running from into the word template.
Hi have been experimenting with this code but not sure if it is the correct way to do it.
Code:
Getfile = "C:my_Word_Template.Doc" 'Some location input for my word document not actual code used
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(Getfile)
Set objRange = objDoc.Bookmarks("bkExcelEmbed").Range 'my bookmark in Word where I want to embed my Excel file.
'This is the part I don't understand, how to get the OLEObject into the Word doc at the bookmark location.
objRange.InlineShapes.OLEObjects.Add Filename:=Filename, Link:=False, DisplayAsIcon:=True, IconFileName:="EXCEL.EXE", IconIndex:=0, IconLabel:=Filename