By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,234 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,234 IT Pros & Developers. It's quick & easy.

how close excel object

P: n/a
Hello, All!
i try the following text from mvps.org

Sub sTestXL()
Dim objXL As Object
Dim strWhat As String, boolXL As Boolean
Dim objActiveWkb As Object

If fIsAppRunning("Excel") Then
Set objXL = GetObject(, "Excel.Application")
boolXL = False
Else
Set objXL = CreateObject("Excel.Application")
boolXL = True
End If
when i adding next code
the excel.exe is not closed after code complete
why?

' objXL.Application.Workbooks.Open "c:\1.xls"
'Set objActiveWkb = objXL.Application.ActiveWorkbook

'With objActiveWkb
'Worksheets("Sheet1").Range("A2").Select
'Worksheets("Sheet1").Range("A2").EntireRow.Insert
' End With

objActiveWkb.Close savechanges:=True

If boolXL Then objXL.Application.QUIT

Set objActiveWkb = Nothing: Set objXL = Nothing
' MsgBox strWhat
End Sub
With best regards, Stalker. E-mail: ra****@inbox.ru

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Killing the object variables doesn't close the app. You need to explicitly
close it
objXL.Quit
--
Reggie

"Half this game is 90% mental."

----------
"Andrei Ryazanov" <ra**@inbox.ru> wrote in message
news:bk***********@ID-101406.news.uni-berlin.de...
Hello, All!
i try the following text from mvps.org

Sub sTestXL()
Dim objXL As Object
Dim strWhat As String, boolXL As Boolean
Dim objActiveWkb As Object

If fIsAppRunning("Excel") Then
Set objXL = GetObject(, "Excel.Application")
boolXL = False
Else
Set objXL = CreateObject("Excel.Application")
boolXL = True
End If
when i adding next code
the excel.exe is not closed after code complete
why?

' objXL.Application.Workbooks.Open "c:\1.xls"
'Set objActiveWkb = objXL.Application.ActiveWorkbook

'With objActiveWkb
'Worksheets("Sheet1").Range("A2").Select
'Worksheets("Sheet1").Range("A2").EntireRow.Insert
' End With

objActiveWkb.Close savechanges:=True

If boolXL Then objXL.Application.QUIT

Set objActiveWkb = Nothing: Set objXL = Nothing
' MsgBox strWhat
End Sub
With best regards, Stalker. E-mail: ra****@inbox.ru

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.