PRB: Programmatic Access to Office XP VBA Project Is Denied (282830)
The information in this article applies to:
- Microsoft Office Excel 2003
- Microsoft Excel 2002
- Microsoft Office PowerPoint 2003
- Microsoft PowerPoint 2002
- Microsoft Office Word 2003
- Microsoft Word 2002
This article was previously published under Q282830 SYMPTOMS Code that is written to automate an Office application and
programmatically manipulate the Microsoft Visual Basic for Applications (VBA)
environment and object model may fail on Office XP with one of the following
error messages: From Visual Basic or VBA:
Run-time error '6068': Programmatic Access to Visual Basic Project is not
trusted From Microsoft Visual C++, Microsoft Foundation Classes
(MFC), or ActiveX Template Library (ATL): HRESULT =
0x800A17B4 (-2146822220) "Programmatic Access to Visual Basic Project is not
trusted" The same code works without error on computers with Office
97 and Office 2000. CAUSE Office XP adds a security option to deliberately lock out
programmatic access to the VBA object model from any Automation client unless a
user chooses to permit such access. This is a per user and per application
setting, and denies access by default.
This security option makes it
more difficult for unauthorized programs to build "self-replicating" code that
can harm end-user systems. RESOLUTION For any Automation client to be able to access the VBA
object model programmatically, the user running the code must explicitly grant
access. To turn on access, the user must follow these steps:
- Open the Office application in question. On the Tools menu, click Macro, and then click Security to open the Macro Security dialog box.
- On the Trusted Sources tab, click to select the Trust access to Visual Basic Project check box to turn on access.
- Click OK to apply the setting. You may need to restart the application for
the code to run properly if you automate from a Component Object Model (COM)
add-in or template.
Modification Type: | Major | Last Reviewed: | 12/15/2003 |
---|
Keywords: | kbAutomation kbprb KB282830 |
---|
|