Results 1 to 15 of 15

Thread: [RESOLVED] Closing Excel with VBA

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    6

    Resolved [RESOLVED] Closing Excel with VBA

    I need some help on this, I have looked around and found some posts, but I can't get it to work.

    I am opening an Excel file with windows scheduler on our server. Once the file is open, it automatically updates and I have written a VBA macro to save and close it. My problem is that Excel itself does not close, just the workbook closes. How do I get Excel to fully close?

    Here is my vba... Thanks!!
    VB Code:
    1. Public Sub CloseAll()
    2.  
    3. Dim Wb As Workbook
    4. SaveAll
    5. For Each Wb In Workbooks
    6.     If Wb.Name <> ThisWorkbook.Name Then
    7.         Wb.Close savechanges:=True
    8.         Set Wb = Nothing
    9.     End If
    10.    
    11. Next Wb
    12. ThisWorkbook.Close savechanges:=True
    13. Set Wb = Nothing
    14.  
    15. End Sub
    Last edited by Hack; Mar 3rd, 2006 at 01:10 PM. Reason: Added [vbcode] [/vbcode] tags and for more clarity.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width