(/iropracy
New Member
- Joined
- Nov 11, 2011
- Messages
- 3
Hey everyone -
I have never had to come to a forum to find help... but here we are. I appreciate your responses.
I am simply trying to replicate the following actions in excel using VBA:
This seems very easy... but excel keeps crashing when I try to do it. I keep getting the "Send Error Report - Excel has Crashed" window.
The error along with it is an automation error.
Run-time error '-2147417851 (80010105)
Automation Error
The server through an exception.
So let's look at the code.
I have tried the code between the asterisks without adding a new application. I only add a new application so my current app will not crash. Can someone else try this code... is it my PC?
If vFile was a different filetype, say .doc, then it works. Anyone have thoughts?
Can someone either help me replicate the actions as described or help me with this error? I am very surprised... there are no threads on this.
Thanks!
I have never had to come to a forum to find help... but here we are. I appreciate your responses.
I am simply trying to replicate the following actions in excel using VBA:
- Insert > Object
- Create from File
- Display as Icon
- Browse
- Choose Excel File
This seems very easy... but excel keeps crashing when I try to do it. I keep getting the "Send Error Report - Excel has Crashed" window.
The error along with it is an automation error.
Run-time error '-2147417851 (80010105)
Automation Error
The server through an exception.
So let's look at the code.
Code:
Sub Embed()
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application") 'Add an excel application so current excel won't crash
VFile = "C:\Documents and Settings\user\Desktop\Workbook.xls"
With XLApp
.Workbooks.Add
'**********
Set oNewObj = .Workbooks(1).Sheets("Sheet1").OLEObjects.Add(Filename:=VFile, Link:=False, DisplayAsIcon:=True))
'**********
End With
XLApp.Visible = True
End Sub
I have tried the code between the asterisks without adding a new application. I only add a new application so my current app will not crash. Can someone else try this code... is it my PC?
If vFile was a different filetype, say .doc, then it works. Anyone have thoughts?
Can someone either help me replicate the actions as described or help me with this error? I am very surprised... there are no threads on this.
Thanks!