Link to home
Start Free TrialLog in
Avatar of MariaHalt
MariaHaltFlag for United States of America

asked on

How to Embed Excel File into Word Document (as an icon) - Getting compile error

'From within Word VBA getting
'Compile error:  User-defined type not defined
'on Dim line below:

Sub InsertFile()
 
Dim objOLE As oleObject
Set objOLE = ActiveSheet.oleObjects.Add(FileName:="C:\temp\source.xls", Link:=False, DisplayAsIcon:=True)

End Sub
Avatar of hitsdoshi1
hitsdoshi1

Selection.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", FileName:= _
        "", LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
        "C:\WINNT\Installer\\xlicons.exe", _
        IconIndex:=1, IconLabel:="Microsoft Excel Worksheet"
Avatar of MariaHalt

ASKER

Almost there...the icon doesn't look like an Excel icon...the path to xlicons.exe seems incomplete.
ASKER CERTIFIED SOLUTION
Avatar of hitsdoshi1
hitsdoshi1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The numbers were the same, the path was slightly different...

"C:\Windows\\Installer\{90110409-6000-11D3-8CFE-0150048383C9}\xlicons.exe"

Thank you.