Link to home
Start Free TrialLog in
Avatar of Roger
RogerFlag for United Kingdom of Great Britain and Northern Ireland

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?"
Avatar of unknown_routine
unknown_routine
Flag of United States of America image

this.Application.ActiveDocument.Save()
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger

ASKER

unknown_routine    this.Application.ActiveDocument.Save() and this.Application.ActiveDocument.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.AlertResponse = 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.AlertResponse = 1
''ThisDocument.Saved = False
''ThisDocument.Close

'the following OPENS DIALOGUE; closes document and leaves windows open:
''Application.AlertResponse = 0
''ThisDocument.Saved = False
''ThisDocument.Close

'no dialogue & no quit because cant quit if ThisDocument is not yet closed
''Application.AlertResponse = 0
''ThisDocument.Saved = False
''Application.Quit

'NO DIALOGUE and                CLOSE DOC; QUIT APP
''Application.AlertResponse = 1
''ThisDocument.Saved = True
''Application.Quit

'NO DIALOGUE and                CLOSE DOC; QUIT APP
''Application.AlertResponse = 0
''ThisDocument.Saved = True
''Application.Quit

'NO DIALOGUE and                CLOSE DOC
''Application.AlertResponse = 0
''ThisDocument.Saved = True
''ThisDocument.Close

'DIALOGUE SHOWN and        CLOSE DOC
''Application.AlertResponse = 0
''ThisDocument.Saved = False
''ThisDocument.Close

'DIALOGUE SHOWN and        CLOSE DOC; QUIT APP
''Application.AlertResponse = 0
''ThisDocument.Saved = False
''ThisDocument.Close 'must close before appl can quit!
''Application.Quit

'NO DIALOGUE and            CLOSE DOC; QUIT APP
''Application.AlertResponse = 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