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



From: broro183 on

hi Rhino
Perhaps...

Press the big button at the top left - Word Options - Trust Center -
Trust Center Settings - tick "Trust access to..."

hth
Rob


--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: 333
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=182375

[url=&quot;http://www.thecodecage.com&quot;]Microsoft Office Help[/url]

From: Rhino on

"broro183" <broro183.46wxa3(a)thecodecage.com> wrote in message
news:broro183.46wxa3(a)thecodecage.com...
>
> hi Rhino
> Perhaps...
>
> Press the big button at the top left - Word Options - Trust Center -
> Trust Center Settings - tick "Trust access to..."
>
I'll bet that seemed obvious to you but it certainly wasn't to me: I'd never
heard of the Trust Center before :-) I've just had Word 2007 for a few days
and am still getting on to it. Thanks, that solved the problem!

However, it simply revealed a new problem. But this looks more like a macro
problem than a VB one so I'll ask about it elsewhere.

Thanks for your help!

--
Rhino