Y
Yulia Gillerson
Hello!
1. I create new MS Word 2003 document.
2. Add reference to Excel.
3. Insert embedded Excel object.
4. Run the following code:
Function OpenAndCloseExcel()
Dim objWorkBook As excel.Workbook
Dim objExcel As excel.Application
ActiveDocument.InlineShapes(1).OLEFormat.DoVerb
VerbIndex:=wdOLEVerbPrimary
Set objWorkBook = ActiveDocument.InlineShapes(1).OLEFormat.Object
Set objExcel = objWorkBook.Application
objWorkBook.Close
objExcel.Quit
End Function
Function fails - error 1004, method 'close' of object '_workbook' failed.
5. I run the same function again, Excel objext already activated on step 4.
Function does not fails, Excel removed from task manager.
Could you, please, describe
1. Why function fails on step 4?
2. How to close embedded workbook & excel application properly?
Thank you very much in advance.
1. I create new MS Word 2003 document.
2. Add reference to Excel.
3. Insert embedded Excel object.
4. Run the following code:
Function OpenAndCloseExcel()
Dim objWorkBook As excel.Workbook
Dim objExcel As excel.Application
ActiveDocument.InlineShapes(1).OLEFormat.DoVerb
VerbIndex:=wdOLEVerbPrimary
Set objWorkBook = ActiveDocument.InlineShapes(1).OLEFormat.Object
Set objExcel = objWorkBook.Application
objWorkBook.Close
objExcel.Quit
End Function
Function fails - error 1004, method 'close' of object '_workbook' failed.
5. I run the same function again, Excel objext already activated on step 4.
Function does not fails, Excel removed from task manager.
Could you, please, describe
1. Why function fails on step 4?
2. How to close embedded workbook & excel application properly?
Thank you very much in advance.