Visio VBA newbie: Preventing 'Save Change to XXX?' dialog

K

Kevin James

Hi all,
I'm trying to automate a Visio task (Visio2000 SP1) of importing a graphic
into a new Visio document, but I'm always running into the same problem when
I try to close the document.

the general pseudocode is as follows:
1. Open a template file document into a Document object
2. Import a new graphic into it (either a .jpg or a .bmp)
3. Save the import to a new file (objDocument.SaveAs
"c:\imports\newdoc.vsd")
4. Close the document (objDocument.Close)

No matter what I try in Step 4, I keep coming up with a yes/no/cancel dialog
box "Save Changes to newdoc.vsd?", even though I just saved it in Step 3 and
did nothing to that saved document prior to closing the document.

I've tried setting the Document's .Saved property = True just before the
..Close method, but Visio seems to ignore this.

The only other thing I can think of that is that I'm trying to save the
document into Visio 5 format (it's a backward-compatible requirement for this
particular application), and Visio wants to save it to it's native Visio2000
format. Could this be an issue here? I'm quickly running out of ideas...

Thanks in advanced for some possible direction,
Kevin James
 
K

Kari Yli-Kuha

Kevin James said:
Hi all,
I'm trying to automate a Visio task (Visio2000 SP1) of importing a graphic
into a new Visio document, but I'm always running into the same problem when
I try to close the document. ....
I've tried setting the Document's .Saved property = True just before the
.Close method, but Visio seems to ignore this.

How about using Application.AlertResponse:

int iDefaultResponse = Application.AlertResponse ' save present response
Application.AlertResponse = 7 'IDNO
[do eg Document.Close]
Application.AlertResponse = iDefaultResponse ' restore default

/C
 
M

Matt

In Visio 2003 they added ApplicationSettings:
This is from the 2003 Help for this code:
====================
Determines if warning messages appear when the user attempts to save in XML
format drawings that contain errors, such as invalid XML code.

boolRet = object.ShowFileSaveWarnings

object.ShowFileSaveWarnings = boolValue

boolRet Boolean. True if showing file save warnings is enabled; False
if it is disabled.

object Required. An expression that returns an ApplicationSettings
object.

boolValue Required Boolean. True to enable showing file save warnings;
False to disable showing them.



Version added
2003

Remarks
Setting the ShowFileSaveWarnings property is equivalent to setting the Show
file save warnings option on the Save tab in the Options dialog box (Tools
menu

=======================

There are more ApplicationSettings how to suppress or enable many others
Visio dialogs. I've seen it but can't find them at the moment. If the above
doesn't work for you, come back here, push me and I'll dig deeper for the
other code I've seen before.

regrads

Matt



Kari Yli-Kuha said:
Hi all,
I'm trying to automate a Visio task (Visio2000 SP1) of importing a graphic
into a new Visio document, but I'm always running into the same problem when
I try to close the document. ...
I've tried setting the Document's .Saved property = True just before the
.Close method, but Visio seems to ignore this.

How about using Application.AlertResponse:

int iDefaultResponse = Application.AlertResponse ' save present response
Application.AlertResponse = 7 'IDNO
[do eg Document.Close]
Application.AlertResponse = iDefaultResponse ' restore default

/C
 
K

Kevin James

Kevin James said:
Hi all,
I'm trying to automate a Visio task (Visio2000 SP1) of importing a
graphic into a new Visio document, but I'm always running into the same
problem when I try to close the document. ...
I've tried setting the Document's .Saved property = True just before
the .Close method, but Visio seems to ignore this.

How about using Application.AlertResponse:

int iDefaultResponse = Application.AlertResponse ' save present
response Application.AlertResponse = 7 'IDNO
[do eg Document.Close]
Application.AlertResponse = iDefaultResponse ' restore default

/C

Thanks a bunch, Kari. That did the trick.

Kevin James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top