Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 03:56 PM
hek hek is offline
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Closing Excel

Hi,

I've written a routine that opens an existing Excel workbook in a new Excel application instance. However, in a different routine, I wish to close the workbook and quit the application. The code seems to fire off ok but I noticed that the other Excel instance sticks around in the Windows Task Manager. Can anyone help?

Thanks,
joey

Here's the code:

Private app As Excel.Application
Private wb As Excel.Workbook

Private Sub CommandButton1_Click()
    Dim str As String

    str = ThisWorkbook.ActiveSheet.Range("PATH")

    ' open the workbook
    Set app = New Excel.Application
    app.Visible = False

    oldStatusBar = Application.DisplayStatusBar
    Application.DisplayStatusBar = True
    Application.StatusBar = "Please be patient..."

    Set wb = app.Workbooks.Open(str, ReadOnly)

    Application.StatusBar = False
    Application.DisplayStatusBar = oldStatusBar
End Sub


Private Sub CommandButton3_Click()
' On Error Resume Next

    wb.Close False
    Set wb = Nothing
    app.Quit
    Set app = Nothing

End Sub


 
Old October 29th, 2004, 06:28 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try AFTER Set app = Nothing

ThisWorkBook.Close savechanges:=false

-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
 
Old October 29th, 2004, 10:22 AM
hek hek is offline
Registered User
 
Join Date: Oct 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No luck... same problem with another Excel instance running in the Task Manager.

Quote:
quote:Originally posted by BrianB
 Try AFTER Set app = Nothing

ThisWorkBook.Close savechanges:=false

-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.





Similar Threads
Thread Thread Starter Forum Replies Last Post
closing a form mnvijay VS.NET 2002/2003 4 December 18th, 2007 07:20 AM
Closing Excel Workbook rekha_jsr Excel VBA 0 July 9th, 2005 02:40 AM
VBAProject Password closing Excel jdmurcia Excel VBA 1 December 4th, 2004 09:41 AM
closing Form kobystud C# 4 July 1st, 2004 03:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.