Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "Trust Access to Visual Basic Project" checked but getting error 6

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,M issing.Value,Missing.Value);


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

wb.Application.Run(macro,Missing.Value,Missing.Val ue,Missing.Value,Missing.Value,Missing.Value,Missi ng.Value,Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing. Value,Missing.Value,Missing.Value,Missing.Value,Mi ssing.Value,Missing.Value,Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing. Value,Missing.Value,Missing.Value,Missing.Value,Mi ssing.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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default "Trust Access to Visual Basic Project" checked but getting error 6

Now that I have it checked

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

"AsimHussain" wrote in message
...
| 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,M issing.Value,Missing.Value);
|
|
| module =
|
wb.VBProject.VBComponents.Add(VBIDE.vbext_Componen tType.vbext_ct_StdModule);
| module.CodeModule.AddFromString(macroDesc);
| Console.Out.WriteLine("run macro");
|
|
wb.Application.Run(macro,Missing.Value,Missing.Val ue,Missing.Value,Missing.Value,Missing.Value,Missi ng.Value,Missing.Value,
|
Missing.Value,Missing.Value,Missing.Value,Missing. Value,Missing.Value,Missing.Value,Missing.Value,Mi ssing.Value,Missing.Value,Missing.Value,
|
Missing.Value,Missing.Value,Missing.Value,Missing. Value,Missing.Value,Missing.Value,Missing.Value,Mi ssing.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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default "Trust Access to Visual Basic Project" checked but getting error6

The service would not work, because MS Office is designed to be run
under some sort of a user account, read the following link for more
information;

http://support.microsoft.com/default...;EN-US;q257757

I have tried to run this service under some arbitrary user account
(with password) and it seems to work fine upon deployment.

Regards
Asim
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Trust Access to Visual Basic Project" checked but getting error 6 AsimHussain Excel Programming 0 May 6th 09 03:59 PM
trust access to Visual Basic Project checked Boss Excel Programming 4 September 18th 08 01:16 PM
How can I verify if "Trust access to visual basic project" is chec MikeZz Excel Programming 2 July 28th 08 10:25 PM
Trust Access to Visual Basic Project tcb Excel Programming 0 January 9th 08 06:39 PM
Registry key for "Trust access to Visual Basic project" tmarko[_13_] Excel Programming 3 June 14th 04 10:40 AM


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"