My Excel Save and Close Macro seems to be reopening my workbook

Viewed 40

I have a macro assigned to a button that should save any changes and then close only thisworkbook. However, when it runs after saving and closing it immediately starts to download the workbook again.

Here is the code:

Sub SaveAndClose()
    Dim wb As Workbook
    Set wb = ThisWorkbook 'setting workbook
    wb.Save 'saving workbook
    wb.Close (True) ' closing workbook
    Application.Quit 'shutting down Excel
End Sub

Thanks for any help.

1 Answers

Do the following:

Sub SaveAndClose()
    Application.Quit 'shutting down Excel
    Dim wb As Workbook
    Set wb = ThisWorkbook 'setting workbook
    wb.Save 'saving workbook
    wb.Close (True) ' closing workbook
End Sub
Related