On Document Open - Close Document if MAcrosDisabled ?

R

RichardB

Hello, First what the intention is -

I want to protect the background page from being removed from the drawing
set, or replaced in the drawing set. I want my background sheet to be
required on every New PAge, and cannot be removed from existing pages.

I know that in drawing explorer you can protect, but there is no password so
It can be unprotected by an experienced user (?).

I though VBA would be a good solution but if the user disables Macros no
dice.

*** Any suggestion on achieving this protection in Visio2003. I hope it is
easy and I have possibley overlooked the obvious.

How about VBA code on Doc open - if doc.MAcrosEnabled = FALSE then doc.close
? Does not work the code does not run if macrosEnabled = FALSE.


I have considered the following vba -

' no new bage can be added as background
Private Sub Document_PageAdded(ByVal Page As IVPage)
If Page.Background = True Then
Page.Background = False
End If
End Sub

' No delete existing background
Private Function Document_QueryCancelPageDelete(ByVal Page As IVPage) As
Boolean
If Page.Name = "Background" Then
MsgBox ("Its the background")
Document_QueryCancelPageDelete = True
Else
MsgBox ("SOme otherpage")
Document_QueryCancelPageDelete = False
End If
End Function


' Must run MAcro to open document -

' Does not work
Private Sub Document_DocumentOpened(ByVal doc As Visio.IVDocument)
If doc.MacrosEnabled = True Then
MsgBox ("Macros Enabled")
Else
MsgBox ("Please Enable Macro Execution - THis document will not open with
out them. Lower your security level")
doc.Close
End If
End Sub
 
C

Chris Roth [MVP]

Hi RichardB,

You won't be able to get around Macro Security using a macro itself. If the
macros are disabled, then your VBA won't run. You'd need something else
running to do the watching and controlling - ie: some sort of add-on or
add-in that your users are required to have installed. Dunno if that's
realistic for you.


--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 

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