VBA Workbook Savechanges = False still saving and closing workbook when running Macro

前端 未结 1 1775
予麋鹿
予麋鹿 2021-01-26 13:52

I have a main workbook that extracts data from other workbook sheets, then closes the modified workbook suppressing the save option.

other_wb.Close Savech

相关标签:
1条回答
  • 2021-01-26 14:15

    Savechanges is an undefined variable. It is therefore Empty; Empty is falsy, so the expression Savechanges = False evaluates to True, so the call becomes other_wb.Close True, which saves the file.

    You are missing the colon:

    other_wb.Close Savechanges:= False
    

    Put Option Explicit on top of all your code modules to never have to deal with this kind of issues.

    0 讨论(0)
提交回复
热议问题