
Excel closing after closing workbook (OLE automation)
Using Excel 2002. When I start Excel from Word and open a workbook in vba,
Excel closes when I close this workbook.
This is the relevant code:
Dim Ex As Excel.Application
Dim ExBook As Workbook
Dim ExSheet As Worksheet
Const ERR_APP_NOTRUNNING As Long = 429
On Error Resume Next
Set Ex = GetObject(, "Excel.application")
If Err = ERR_APP_NOTRUNNING Then
'Excel not running so start it and open Test.xls
Set Ex = New Excel.Application
Set ExBook = Ex.Workbooks.Open("C:\Test.xls")
Ex.Visible = True
Else
Is this just normal behaviour or am I doing something wrong?
Thanks for any advice.
RBS