christoph123
08-19-2008, 03:15 AM
Hi,
I have a Word Document embedded as OLEObject in an Excel sheet. What I want to do is to store this embedded object as a file on the disc using VBA.
I use the following code to access and store the embedded object:
Dim oleObject As Object
Dim wordDocument As Object
Set oleObject = ActiveWorkbook.Sheets(sheetName).OLEObjects(1)
Set wordDocument = oleObject.Object
wordDocument.SaveAs ("some filename")
The previous code works well if double-click the embedded OLE object, thus get the focus, and then deactivate it by clicking on the Excel sheet. However, after a re-start of Excel, it doesn't work, so I have to double-click the object and then click on the sheet again in order to get it work. Otherwise I get a runtime error.
I also tried to .Activate and set the .Verb property, with no success. Anybody has a solution for that?
Thanks,
Christoph
I have a Word Document embedded as OLEObject in an Excel sheet. What I want to do is to store this embedded object as a file on the disc using VBA.
I use the following code to access and store the embedded object:
Dim oleObject As Object
Dim wordDocument As Object
Set oleObject = ActiveWorkbook.Sheets(sheetName).OLEObjects(1)
Set wordDocument = oleObject.Object
wordDocument.SaveAs ("some filename")
The previous code works well if double-click the embedded OLE object, thus get the focus, and then deactivate it by clicking on the Excel sheet. However, after a re-start of Excel, it doesn't work, so I have to double-click the object and then click on the sheet again in order to get it work. Otherwise I get a runtime error.
I also tried to .Activate and set the .Verb property, with no success. Anybody has a solution for that?
Thanks,
Christoph