开发者

How to avert the save MessageBox prompt in Excel-VBA?

开发者 https://www.devze.com 2023-03-22 17:16 出处:网络
I have a problem here if you look at my codes below after I call the .close line which was the file I initially copied from. It will prompt a save MessageBox message either yes, n开发者_开发百科o, or

I have a problem here if you look at my codes below after I call the .close line which was the file I initially copied from. It will prompt a save MessageBox message either yes, n开发者_开发百科o, or cancel. Is there anyway I can avoid this save message from appearing programmatic if no was the case could I just programmatic program it no instead?


Jon is right to suggest Application.DisplayAlerts and if you want to answer no to a save as you suggest

 Workbooks(Filename1).Close SaveChanges:=False


Try setting the Application.DisplayAlerts to false, then closing. I recommend turning it back on after setting it.

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True


IIRC:

Workbooks(FileName1).Save

If you save it explicitly, it won't have to ask you.

0

精彩评论

暂无评论...
验证码 换一张
取 消