Prevent Overwrite Warning in VBA

前端 未结 2 1978
攒了一身酷
攒了一身酷 2021-01-21 18:34

I am writing a macro to extract XML data from a Web API into a spreadsheet. The first column contains two fields delimited with a comma so I have extended the macro to insert a

相关标签:
2条回答
  • 2021-01-21 19:07

    source: SolutionSite

    To suppress the warnings:

    Application.DisplayAlerts = False
    

    To activate the warnings:

    Application.DisplayAlerts = True
    
    0 讨论(0)
  • 2021-01-21 19:15
    Application.DisplayAlerts = False
    

    Two important points from the documentation:

    [...] when a message requires a response, Microsoft Excel chooses the default response.

    and

    If you set [DisplayAlerts] to False, Microsoft Excel sets [it back] to True when the code is finished [...]

    meaning you'll still have the standard "Do you want to save before closing?" etc. prompts during normal Excel use.

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