Unable to use Excel.Application

Hi All,

I try to use Dim oExcel As New Excel.Application for my web application using VB.NET.
But it give me following error
System.UnauthorizedAccessException: Access is denied. at Orders.GetDeliverySchedule.getfile() in c:\inetpub\wwwroot\Orders\GetDeliverySchedule.aspx.vb:line 44 at Orders.GetDeliverySchedule.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Orders\GetDeliverySchedule.aspx.vb:line 36

I had Imports Excel library into my program reference.

The OS running on my server which is using for deployment is Window Server 2003. Then it willl give me the error msg above.
But if i use my development PC which running on Win XP. Then i will be able to run and generate the excel file without any error.

Can anyone advice, what should i do?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

vjc2003Connect With a Mentor Commented:
Do you have administrator rights on the machine?.
To Launch Excel Application you need to set the permissions in DCOM Config of the machine.
By default only administrator have the right to launch/activate..
Go to Administrative Tools>Component Services>DCOM Config and see security properties for MS Excel

If you are running this as a webapp you'll need to grant permission to the Internet Guest Account as well.
You will need MS Excel to be installed and runnable on the computer where the app runs.

If it is a problem with different versions of Excel, I would suggest you to use late binding instead, (and remove the reference to Excel).

Dim oApp as Object

Dim oSheet as Object

Do you have excel installed in your server? Also try using some alternate method to generate excel instead.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

ian_khoo_scAuthor Commented:
Yes. I had installed excel into my server.
I had try 2 version of excel. First time i install in excel 97.
But it still not working.
Then i add in Excel 2002.

I guess it not realated to excel version but with permission for you to run some other process. Here excel is other process which you are trying to use in ur web app. Why dont u try to go with method to export to excel without using. I think you can get tons of them easily.
ian_khoo_scAuthor Commented:
Can you provide a simple example?
Thanks for your help
What are you exporting to excel ? a datagrid?

try searching EE you can get tons of examples.

one of them is here..

All Courses

From novice to tech pro — start learning today.