问题
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, no, 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?
回答1:
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
回答2:
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
回答3:
IIRC:
Workbooks(FileName1).Save
If you save it explicitly, it won't have to ask you.
来源:https://stackoverflow.com/questions/6824816/how-to-avert-the-save-messagebox-prompt-in-excel-vba