Avatar of MariaHalt
MariaHalt
Flag 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
Editors IDEsMicrosoft Word

Avatar of undefined
Last Comment
MariaHalt

8/22/2022 - Mon
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"
MariaHalt

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

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
MariaHalt

ASKER
The numbers were the same, the path was slightly different...

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

Thank you.
Your help has saved me hundreds of hours of internet surfing.
fblack61