From: Rhino on
I am revisiting an old VBScript that I wrote several years ago. It basically
opens an existing Word document, then exports the macros associated with
that document.

This is the script:

===========================
' Get arguments into variables
If WScript.Arguments.Count < 1 Then
MsgBox "Too few arguments; expecting one."
WScript.Quit
Elseif WScript.Arguments.Count > 1 then
MsgBox "Too many arguments; expecting one."
WScript.Quit
Else
strArg1 = WScript.Arguments.Item(0)
End If

' Find path for MyDocuments folder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H5&)
strMyDocPath = objFolder.Self.Path

' Start Word Application, open resume.doc in MyDocuments
Set oWd = CreateObject("Word.Application")
oWd.Visible = False
Set oDoc = oWd.Documents.Open(strMyDocPath & "\rhino-resume.doc")

'Run macro named exportMacros, which has one argument
retcde = oWd.Run("exportMacros",strArg1)

'Save changes to doc on closing and quit Word
oDoc.Save
oDoc.Close
oWd.Quit
Set oWd = Nothing

Set objShell = Nothing

WScript.quit(retcde)
===========================

When I execute the script, I get a message dialog that says:

==================
Microsoft Visual Basic

Run-time error '6068':

Programmatic access to Visual Basic Project is not trusted.

[Continue] [End] [Debug] [Help]
===================

The "Continue" button is greyed out which is unfortunate, because that's the
one I'd like to press....

I don't remember seeing this error when I ran the script in the past but I
was running Word 2002 at the time. I strongly suspect that something changed
in Word 2007 to increase security....

Anyway, what do I do to satisfy the script that I want to run the
exportMacros macro and that I trust the code that I am running?

Also, just in case further problems arise, can someone advise me where to
find detailed documentation on Visual Basic runtime errors?

I'm an experienced programmer but have VERY little experience with Visual
Basic; I'm mostly a Java guy!

I'm running Windows XP SP2.

--
Rhino