Programmactic access to Visual Basic Project is not trusted

P

Peter

Hello everyone,

Because of this piece fo code:
...
Dim ModuleCount as Long (?)

ModuleCount = ThisWorkbook.VBProject.VBComponents.Count
Sheets.Add After:=Sheets(ModuleCount)

I get this error message:
"Programmactic access to Visual Basic Project is not trusted"

(What good is it then?)

Does anyone know how to circumvent this?


TIA

Peter
 
F

Frank Kabel

Hi
goto 'Tools - Macros - Security' and on the second tab of this dialog
allow access to the VBA project
 
K

keepITcool

NOTE:

if you are using Excel 2003 the box in
macro security options is greyed out.

the registry setting was moved from user to machine
and you can no longer change it from the UI.

Run the program regedit.exe
goto:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Excel\Security
Add or Change a DWORD named AccessVBOM to Value 1
 
F

Frank Kabel

Hi Jurgen
for me (using Excel 2003 / German) no problem to change this setting in
the UI directly. But I'm logged in as admin. So could be the reason for
this
 
S

Stephen Bullen

Hi Peter,
Dim ModuleCount as Long (?)

ModuleCount = ThisWorkbook.VBProject.VBComponents.Count
Sheets.Add After:=Sheets(ModuleCount)

All the replies so far have explained how to turn it back on, but why
are you using it anyway? If you want to add a sheet at the end, use:

ActiveWorkbook.Sheets.Add After:=ActiveWorkbook.Sheets.Count

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk
 

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