Can Visio’s macro warning prompt be surpressed when automating in

S

SteveHiner

I'm automating Visio 2003 from a VB.NET app. My code looks like this (with
the uninteresting stuff removed):

Dim objApp As New Microsoft.Office.Interop.Visio.InvisibleApp
objApp.Settings.ShowFileOpenWarnings = False
Dim objDoc As Microsoft.Office.Interop.Visio.Document
objDoc = objApp.Documents.Open(VisioFilename)

I've found that the last line causes Visio to raise a hidden MessageBox
saying:
"Macros in this document are disabled because the security level is high,
and the macros have not been digitally signed or verified as safe. To run the
macros, you can either have them signed or change your security level."

Since this is going to be running on computers I don't control with files I
don't control neither of those options works for me. I really don't care that
the macros are disabled, I'm just using Visio to convert the file from it's
native format to SVG. I certainly don't want to suggest to users that they
lower the security level, nor would I want to lower it for them.

As you can see from my code above, I turn off file open warnings but that
doesn't seem to include the macro warning. Since I'm using Visio.InvisibleApp
it turns out the warning isn't displayed to the user. Running a visible
instance of Visio won't help because I'm creating a batch converter, even if
the message was visible it means the user would have to click OK for each
file. That would make the batch conversion feature essentially useless.

I see that the Visio class has a VBAEnabled property but it's read only. If
there was a way I could just turn off VBA when opening the file it would
likely solve the problem. I've looked all through the properties and through
the Settings property on the class and can't find anything. I've done a bunch
of Google searching and can't find anything that addresses this issue.

Anyone know if that warning can be suppressed when using automation with
Visio? Would it be possible with Visio 2007?
 
A

Andy

I'm automating Visio 2003 from a VB.NET app. My code looks like this (with
the uninteresting stuff removed):

Dim objApp As New Microsoft.Office.Interop.Visio.InvisibleApp
objApp.Settings.ShowFileOpenWarnings = False
Dim objDoc As Microsoft.Office.Interop.Visio.Document
objDoc = objApp.Documents.Open(VisioFilename)

I've found that the last line causes Visio to raise a hidden MessageBox
saying:
"Macros in this document are disabled because the security level is high,
and the macros have not been digitally signed or verified as safe. To runthe
macros, you can either have them signed or change your security level."

Since this is going to be running on computers I don't control with filesI
don't control neither of those options works for me. I really don't care that
the macros are disabled, I'm just using Visio to convert the file from it's
native format to SVG. I certainly don't want to suggest to users that they
lower the security level, nor would I want to lower it for them.

As you can see from my code above, I turn off file open warnings but that
doesn't seem to include the macro warning. Since I'm using Visio.InvisibleApp
it turns out the warning isn't displayed to the user. Running a visible
instance of Visio won't help because I'm creating a batch converter, evenif
the message was visible it means the user would have to click OK for each
file. That would make the batch conversion feature essentially useless.

I see that the Visio class has a VBAEnabled property but it's read only. If
there was a way I could just turn off VBA when opening the file it would
likely solve the problem. I've looked all through the properties and through
the Settings property on the class and can't find anything. I've done a bunch
of Google searching and can't find anything that addresses this issue.

Anyone know if that warning can be suppressed when using automation with
Visio?  Would it be possible with Visio 2007?

That would suggest to me that the visio file you are opening contains
macros that have not been signed.

You could try using OpenEx(filename,visOpenMacrosDisabled)

Alternatively, rather than starting a visio application, could you not
embed the activex drawing control.
 
C

Chris Roth [Visio MVP]

Hi Steve,

There is an OpenEx method as well. This allows you to pass flags in to
specify various open behaviors.

One of the flags allows you to "not allow" macros. This should stop the
warning messages from appearing. Usually, when opening other documents
automatically, you don't need the macros to be active. Hopefully this is
the case with you.

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
S

SteveHiner

Thank you so much. I don't know how I missed that. It is exactly what I
needed and it works perfectly.

Thanks for helping out Chris!

Steve
 

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