S
SteveMe
I would like to, at runtime & within a VBA macro, delete the entire VB
Project for a Visio document .
Background:
We have automation that is triggered automatically when the document is
opened for the first time. At the completion of this automation, we want to
completely remove the project so that users of the document will not receive
Macro Trust warnings.
We've figured out how to remove all the code, macros & modules. But even
after everything is deleted, we're still receiving the Macro Trust warning to
ENABLE macros.
Our question is:
How do we completely delete the project? If not possible, is there
another way to avoid the Macro Trust warning for a particular document...
since the project is completely empty?
Here's what we've done:
1. We've figured out how to delete macros and modules from the example at
http://www.ozgrid.com/VBA/delete-module.htm
2. We've also figured out how to delete the code from a VBComponent, such as:
Set vbCom = Application.Vbe.ActiveVBProject.VBComponents
Dim numLines As Integer
numLines = vbCom.Item("ThisDocument").CodeModule.CountOfLines
vbCom.Item("ThisDocument").CodeModule.DeleteLines 1, numLines
3. We tried to remove the active project, but this resulted in a "Run-time
error 440":
Application.Vbe.VBProjects.Remove Application.Vbe.ActiveVBProject
Thank you
Steve
Project for a Visio document .
Background:
We have automation that is triggered automatically when the document is
opened for the first time. At the completion of this automation, we want to
completely remove the project so that users of the document will not receive
Macro Trust warnings.
We've figured out how to remove all the code, macros & modules. But even
after everything is deleted, we're still receiving the Macro Trust warning to
ENABLE macros.
Our question is:
How do we completely delete the project? If not possible, is there
another way to avoid the Macro Trust warning for a particular document...
since the project is completely empty?
Here's what we've done:
1. We've figured out how to delete macros and modules from the example at
http://www.ozgrid.com/VBA/delete-module.htm
2. We've also figured out how to delete the code from a VBComponent, such as:
Set vbCom = Application.Vbe.ActiveVBProject.VBComponents
Dim numLines As Integer
numLines = vbCom.Item("ThisDocument").CodeModule.CountOfLines
vbCom.Item("ThisDocument").CodeModule.DeleteLines 1, numLines
3. We tried to remove the active project, but this resulted in a "Run-time
error 440":
Application.Vbe.VBProjects.Remove Application.Vbe.ActiveVBProject
Thank you
Steve