Runtime Error 6068 Programmatic Access to Visual Basic Project is not trusted

K

Keith Lubell

The following code generates this error:

Dim appWord As New Word.Application
Dim strCodePath As String
strCodePath = "x:\Macro Modules\"

Dim temNorm As Word.Template
Dim strBas As String

Set temNorm = appWord.NormalTemplate

DoEvents
'This loops through all the export mods and imports them into the normal.dot
vbproject
strBas = Dir(strCodePath & "*.bas")
Do Until strBas = ""
'the dir function doesn't return the path, so we add it here
strBas = strCodePath & strBas

'-- FAILS ON IMPORT STATEMENT
temNorm.VBProject.VBComponents.Import strBas

DoEvents
'calling dir with no arguments returns the next file matching the
pattern
strBas = Dir
Loop

I have reset the macro security on WORD 2002 to LOW and I have checked the
allow access to VB Projects, but after rebooting the machine. It still does
not work. I assume this is to prevent Viruses from affecting the normal.dot,
but I am creating docs for a special mail merge app. I am going to try to
create another template with these injected macros. Any other ideas?
 

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