From: Rhino on 24 Feb 2010 17:03 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 24 Feb 2010 19:03 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="http://www.thecodecage.com"]Microsoft Office Help[/url]
From: Rhino on 25 Feb 2010 08:46 "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
|
Pages: 1 Prev: user form that retrieves data from Microsoft Access query Next: Removing External Data |