Solved

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

Posted on 2014-03-27
3
761 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 48

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article we’ll examine containers. We’ll explore lists (http://www.experts-exchange.com/Microsoft/Applications/M…
The ability to add structure to Visio diagrams using containers, lists and callouts is one of my favorite features in Visio 2010. In this article I’ll describe a mashup of containers and lists that meet a real-world need. Prior to reading this ar…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

760 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

24 Experts available now in Live!

Get 1:1 Help Now