Programmatic access to VB project

X

xargon

Hi everyone,

I am trying a simple example for MS that allows me to interject code into
a VB project bodule. However, I always get the run time error that
"Programmatic Access to VB Project is disabled".

My question is how I can enable it. I am using Visio 2003.

Thanks n cheers!
xargon
 
C

Chris Roth [ Visio MVP ]

It's either a security thing or a reference to VB's project editing
capabilities.

I found the following in the Visio/VBA help.

--

Hope this helps,

Chris Roth
Visio MVP

------------------------
Example
This VBA macro shows how to print the names of libraries referenced by a VBA
project in the Immediate window.

Before running this code, make sure the Trust access to Visual Basic Project
check box is selected on the Trusted Publishers tab in the Security dialog
box (on the Tools menu, click Options, click the Security tab, and then
click the Macro Security button).

Public Sub VBProject_Example()

Dim varThisProject As Variant
Dim intReferences As Integer

Set varThisProject = ThisDocument.VBProject

intReferences = varThisProject.References.Count
While intReferences > 0
Debug.Print varThisProject.References(intReferences).Name
intReferences = intReferences - 1
Wend

End Sub
 
C

Chris Roth [ Visio MVP ]

It's either a security thing or a reference to VB's project editing
capabilities. You're getting into "macro virus territory", so this might be
a pain in the butt.

I found the following in the Visio/VBA help.

--

Hope this helps,

Chris Roth
Visio MVP

------------------------
Example
This VBA macro shows how to print the names of libraries referenced by a VBA
project in the Immediate window.

Before running this code, make sure the Trust access to Visual Basic Project
check box is selected on the Trusted Publishers tab in the Security dialog
box (on the Tools menu, click Options, click the Security tab, and then
click the Macro Security button).

Public Sub VBProject_Example()

Dim varThisProject As Variant
Dim intReferences As Integer

Set varThisProject = ThisDocument.VBProject

intReferences = varThisProject.References.Count
While intReferences > 0
Debug.Print varThisProject.References(intReferences).Name
intReferences = intReferences - 1
Wend

End Sub
 
C

Chris Roth [ Visio MVP ]

It's either a security thing or a reference to VB's project editing
capabilities. You're getting into "macro virus territory", so this might be
a pain in the butt.

I found the following in the Visio/VBA help.

--

Hope this helps,

Chris Roth
Visio MVP

------------------------
Example
This VBA macro shows how to print the names of libraries referenced by a VBA
project in the Immediate window.

Before running this code, make sure the Trust access to Visual Basic Project
check box is selected on the Trusted Publishers tab in the Security dialog
box (on the Tools menu, click Options, click the Security tab, and then
click the Macro Security button).

Public Sub VBProject_Example()

Dim varThisProject As Variant
Dim intReferences As Integer

Set varThisProject = ThisDocument.VBProject

intReferences = varThisProject.References.Count
While intReferences > 0
Debug.Print varThisProject.References(intReferences).Name
intReferences = intReferences - 1
Wend

End Sub
 

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