Solved

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

Posted on 2014-03-27
3
818 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 15

Expert Comment

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

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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