Problems with generating module

jojo1974

New member
Joined
Oct 30, 2009
Messages
1
Programming Experience
5-10
Hi, I am hoping someone can help with a problem I am having

I am using ASP (VB).Net 2003 on Windows Server 2003 and I am trying to create a web application which dynamically creates an excel spreadsheet which has a module included. When I run this on the local host it works fine but once I load it onto the server I get the following error message

HRESULT = 0x800A17B4 "Programmatic Access to Visual Basic Project is not trusted

I am using the following VB.Net code
Code:
Dim xlmodule As Object 'VBComponent
xlmodule = xlbook.VBProject.VBComponents.Import(PathToImport & "Module1.bas")If I turn off the code then it will load the spreadsheet without the module but the module is the critical part of the spreadsheet.

I have tried changing permissions but this is running on a client and not a physical machine.

Does anyone have any ideas?

Regards

Jo
 
Hi

I believe you are using Office 2002 or above
Cause for this error:-
Office 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.

Remedy:-

This security option makes it more difficult for unauthorized programs to build "self-replicating" code that can harm end-user systems.

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.

Office 2003 and Office XP
Open the Office 2003 or Office XP 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.

Office 2007
Open the 2007 Microsoft Office system application in question. Click the Microsoft Office button, and then click Application Options.
Click the Trust Center tab, and then click Trust Center Settings.
Click the Macro Settings tab, click to select the Trust access to the VBA project object model check box, and then click OK.
Click OK.

Thanks,
Manoj
 
Back
Top