Sorry, I didn't read your question properly. You said Excel is closed by
user later, not in you routine so don't use Quit.
I didn't try but am surprised your Workbooks open line works.
This works for me in Word without leaving Excel in the taskbar when user
quits:
Sub Test()
Dim xlApp As Object
Dim xlWB As Object
Set xlApp = CreateObject("excel.application") ' new instance or try
GetObject ?
'assumes c\:test.xls exists
Set xlWB = xlApp.Workbooks.Open("C:\test.xls")
xlApp.Visible = True
Set xlWB = Nothing
Set xlApp = Nothing
End Sub
FWIW, the statement "End" on it's own should reset word vba, but shouldn't
be necessary and not recommended. Do you still need
VB scripting?
Regards,
Peter T
"VBA Dabbler" wrote in message
...
Peter,
Thanks for your response. I tried this also - it does not work. Reason
being, it closes Excel, but does not release the object created in the
VBProject.
The only thing I found that works is to reset the project. Do you know
how
to do that with VB scripting?
Thanks,
VBA Dabbler
"Peter T" wrote:
Maybe -
xlApp.Quit
set xlApp = nothing
Regards,
Peter T
"VBA Dabbler" wrote in message
...
How do you clear an object from the VBProject once it has served its
usefulness?
I've done the following:
1. Opened a workbook from a Word VBProject with the following code:
Dim xlApp As Excel.Application
Dim FileString As String
FileString = "C:\MyDocuments\MyWorkbook.xls"
Excel.Application.Visible = True
Workbooks.Open (FileString) 'Focus is now on the workbook
2. Closed workbook by closing Excel
I've found that there is still an instance of the an object reference
to
the
Excel app - there is the "Excel.exe" process in the Windows
Taskmanager.
I've found that when I reset the VBProject where the above code
resides,
the
instance is cleared and the "Excel.exe" process in the Windows
Taskmanager
is
removed.
Do you know how to selectively clear the instance of the object
reference
in
the VBProject?
Thanks,
VBA Dabbler