Solved

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

Posted on 2014-03-27
3
810 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 50

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Compare Excel spreadsheet question. 2 23
Excel style change characters to English characters. 2 18
Converting time 4 35
add a column label to a list object using VBA 2 17
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 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