Embedding the Excel File in a Word Report

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.

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
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Watch MrExcel Video

Forum statistics

Threads
1,109,019
Messages
5,526,290
Members
409,694
Latest member
bastos21

This Week's Hot Topics

Top