Solved

How to force a file save in visio without a windows dialogue box

Posted on 2014-03-27
3
775 Views
Last Modified: 2014-03-27
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?"
0
Comment
Question by:Kelvin4
3 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39958672
this.Application.ActiveDocument.Save()
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39958714
Hi,

pls try

Application.AlertResponse = 1 ' or 6 Not sure (vbOk or vbYes)
ActiveDocument.Save
Application.AlertResponse = 0 

Open in new window

Regards
0
 

Author Closing Comment

by:Kelvin4
ID: 39959748
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding Text that self adjusts in a Cell 8 33
Fixing a embedded format 7 29
File not loading into PowerPivot 4 9
Help with Excel formula 6 38
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now