Roger
asked on
How to force a file save in visio without a windows dialogue box
Using vba to close a visio file, how do I force the visio file to be saved, and suppress the windows alert dialogue box which asks "Save, or not to Save?"
this.Application.ActiveDoc ument.Save ()
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
unknown_routine this.Application.ActiveDoc ument.Save () and this.Application.ActiveDoc ument.Save are bugs
Rgonzo1971 Thanks; and this is how is seems to me when I extend the code to close the document or quit the application. Could you say if the logic below is correct?
Appreciately, Kelvin
=========== LOGIC =====================
'Application.AlertResponse = 0 means: no dialogue has been shown, it will be shown if .Saved = false
'Application.AlertResponse = 1 means: dialogue has been set as shown, so it wont appear even if .Saved = false
'.Saved = 0 means no save has been done
'.Saved = 1 means save has been set as done, even if there is stuff to save
Application.AlertResponse = 1
ThisDocument.Saved = False
This pair - prevents the process from completing:. There is no dialogue to opt for Save/Dont Save / Cancel, yet there is a need to make a decision, as Save = false. So the Document cannot close in response to code: ThisDocument.Close
========== RESULTS ======================
'the following yields NO DIALOGUE; closes document and leaves windows open:
''Application.AlertRespons e = 1 or 0
''ThisDocument.Saved = True 'if .Saved = True then no Alert need be shown (nothing to save)
''ThisDocument.Close 'if .Saved = False Alert will be shown if .AlertResponse = 0
'No dialogue; no close (see Logic)
''Application.AlertRespons e = 1
''ThisDocument.Saved = False
''ThisDocument.Close
'the following OPENS DIALOGUE; closes document and leaves windows open:
''Application.AlertRespons e = 0
''ThisDocument.Saved = False
''ThisDocument.Close
'no dialogue & no quit because cant quit if ThisDocument is not yet closed
''Application.AlertRespons e = 0
''ThisDocument.Saved = False
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons e = 1
''ThisDocument.Saved = True
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons e = 0
''ThisDocument.Saved = True
''Application.Quit
'NO DIALOGUE and CLOSE DOC
''Application.AlertRespons e = 0
''ThisDocument.Saved = True
''ThisDocument.Close
'DIALOGUE SHOWN and CLOSE DOC
''Application.AlertRespons e = 0
''ThisDocument.Saved = False
''ThisDocument.Close
'DIALOGUE SHOWN and CLOSE DOC; QUIT APP
''Application.AlertRespons e = 0
''ThisDocument.Saved = False
''ThisDocument.Close 'must close before appl can quit!
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons e = 0
'ThisDocument.Saved = True
''ThisDocument.Close 'must close before appl can quit!
''Application.Quit
'DIALOGUE SHOWN and CLOSE DOC
Application.AlertResponse = 0
ThisDocument.Saved = False
ThisDocument.Close
Rgonzo1971 Thanks; and this is how is seems to me when I extend the code to close the document or quit the application. Could you say if the logic below is correct?
Appreciately, Kelvin
=========== LOGIC =====================
'Application.AlertResponse
'Application.AlertResponse
'.Saved = 0 means no save has been done
'.Saved = 1 means save has been set as done, even if there is stuff to save
Application.AlertResponse = 1
ThisDocument.Saved = False
This pair - prevents the process from completing:. There is no dialogue to opt for Save/Dont Save / Cancel, yet there is a need to make a decision, as Save = false. So the Document cannot close in response to code: ThisDocument.Close
========== RESULTS ======================
'the following yields NO DIALOGUE; closes document and leaves windows open:
''Application.AlertRespons
''ThisDocument.Saved = True 'if .Saved = True then no Alert need be shown (nothing to save)
''ThisDocument.Close 'if .Saved = False Alert will be shown if .AlertResponse = 0
'No dialogue; no close (see Logic)
''Application.AlertRespons
''ThisDocument.Saved = False
''ThisDocument.Close
'the following OPENS DIALOGUE; closes document and leaves windows open:
''Application.AlertRespons
''ThisDocument.Saved = False
''ThisDocument.Close
'no dialogue & no quit because cant quit if ThisDocument is not yet closed
''Application.AlertRespons
''ThisDocument.Saved = False
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons
''ThisDocument.Saved = True
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons
''ThisDocument.Saved = True
''Application.Quit
'NO DIALOGUE and CLOSE DOC
''Application.AlertRespons
''ThisDocument.Saved = True
''ThisDocument.Close
'DIALOGUE SHOWN and CLOSE DOC
''Application.AlertRespons
''ThisDocument.Saved = False
''ThisDocument.Close
'DIALOGUE SHOWN and CLOSE DOC; QUIT APP
''Application.AlertRespons
''ThisDocument.Saved = False
''ThisDocument.Close 'must close before appl can quit!
''Application.Quit
'NO DIALOGUE and CLOSE DOC; QUIT APP
''Application.AlertRespons
'ThisDocument.Saved = True
''ThisDocument.Close 'must close before appl can quit!
''Application.Quit
'DIALOGUE SHOWN and CLOSE DOC
Application.AlertResponse = 0
ThisDocument.Saved = False
ThisDocument.Close