Removing VBA Project On the Fly

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
 
P

Paul Herber

I would like to, at runtime & within a VBA macro, delete the entire VB
Project for a Visio document .

A problem is that it's the code in the project that is running, it
can't delete itself. Unless you can get the code in another document
to delete the code.

However, it might just be far easier to splash out $80 or so for a
cheap code signing certificate. Comodo.
 

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