"Trust Access to Visual Basic Project" checked but getting error 6


A

AsimHussain

Hello,

I have a C# service which basically looks at a directory and if it finds any
..XLS (2003) file, it would run a macro to save that file as an HTML (with
interaction) somewhere else.

Please note that when I run the service in Debug mode, it works fine,
however, when I build a release version, and run it , the service always
fails giving the following error:

"Programmatic access to Visual Basic Project is not trusted"

I have looked this up on the internet and they all said that the work around
is to check the "Trust Access to Visual Basic Project" in Excel 2003,
Tools-->Macro-->Security-->Trusted Publishers.

Now that I have it checked (and the minimum macro security enabled), I am
still not able to get the service to work!! and I am still getting the exact
same error message.

I would appreciate if you could help me out here.

The code for executing the macro is given below:


Excel.Application xl = null;
Excel._Workbook wb = null;
Excel._Worksheet sheet = null;
VBIDE.VBComponent module = null;

xl = new Excel.Application();
wb = xl.Workbooks._Open(savePath + @"\workbook\" +
fileName,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);


module =
wb.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule);
module.CodeModule.AddFromString(macroDesc);
Console.Out.WriteLine("run macro");

wb.Application.Run(macro,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);

I appreciate all the help that I can get.

Just for completion, the service was built using VS2003.NET on Windows 2003
and it is making use of Excel 2003.

Regards
Asim
 
Ad

Advertisements

H

Homey

Now that I have it checked

after that and you close excel is it still checked when you start excel
again?

| Hello,
|
| I have a C# service which basically looks at a directory and if it finds
any
| .XLS (2003) file, it would run a macro to save that file as an HTML (with
| interaction) somewhere else.
|
| Please note that when I run the service in Debug mode, it works fine,
| however, when I build a release version, and run it , the service always
| fails giving the following error:
|
| "Programmatic access to Visual Basic Project is not trusted"
|
| I have looked this up on the internet and they all said that the work
around
| is to check the "Trust Access to Visual Basic Project" in Excel 2003,
| Tools-->Macro-->Security-->Trusted Publishers.
|
| Now that I have it checked (and the minimum macro security enabled), I am
| still not able to get the service to work!! and I am still getting the
exact
| same error message.
|
| I would appreciate if you could help me out here.
|
| The code for executing the macro is given below:
|
|
| Excel.Application xl = null;
| Excel._Workbook wb = null;
| Excel._Worksheet sheet = null;
| VBIDE.VBComponent module = null;
|
| xl = new Excel.Application();
| wb = xl.Workbooks._Open(savePath + @"\workbook\" +
|
fileName,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
|
|
| module =
|
wb.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule);
| module.CodeModule.AddFromString(macroDesc);
| Console.Out.WriteLine("run macro");
|
|
wb.Application.Run(macro,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
|
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
|
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
| Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);
|
| I appreciate all the help that I can get.
|
| Just for completion, the service was built using VS2003.NET on Windows
2003
| and it is making use of Excel 2003.
|
| Regards
| Asim
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top