Closing Excel Application using VBA

前端 未结 8 1236
忘了有多久
忘了有多久 2020-11-29 04:44

I have used the following without success. The active workbook closes, indeed, but the excel window remains open.

Application.ActiveWindow.Close SaveChanges:         


        
8条回答
  •  感动是毒
    2020-11-29 05:02

    In my case, I needed to close just one excel window and not the entire application, so, I needed to tell which exact window to close, without saving it.

    The following lines work just fine:

    Sub test_t()
      Windows("yourfilename.xlsx").Activate
      ActiveWorkbook.Close SaveChanges:=False
    End Sub
    

提交回复
热议问题