Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I wish to execute an excel with macros using ASP.NET 2.0 and C#. I tried using interop services and was able to execute in my local system but unable to do so in server. Then I created a console application to open the excel containing macros and again I was able to do in local system perfectly but not in server. The problem is when I run the exe manually (i.e by double clicking) I am able to see the excel macros being executed but when I try using website it just doesn't opens. Any Input on this is welcome!
Posted
Updated 15-Dec-10 5:53am
v2
Comments
Dylan Morley 15-Dec-10 5:38am    
OK so how are you executing the application on the server? You say you double click locally, but on the server 'I try using website it just doesnot opens.'

Please explain when you mean here. Is your website trying to execute the process? How are you starting the process? e.g. you use Process.Start

Also, any exception messages?
imdarklord 15-Dec-10 7:45am    
Hi Dylan,
thanks for the reply. The macro in the excel connects to the database, copies the record in the workbooks, then again copies the whole workbook into a new workbook, stores the new workbook in a desired location.

My website picks the latest workbook from the location. I am using the exe to open the first excel(with macros). Using process.start I am executing the exe. This works fine in local system, but when i try to fire the exe from the website in server, it gives the file not found error as the new workbook is not copied in the desired location. Hope this clears your doubt.
Manfred Rudolf Bihy 15-Dec-10 9:39am    
Is MS Excel installed on you webserver? What exactly do you mean by "picks the latest workbook from the location" ?
imdarklord 16-Dec-10 7:01am    
Yes MS Excel is installed in the server and macros has been enabled. By latest workbook I mean the workbook that is created by the macro and stored in Temp folder. The website uses the Temp folder location to show this workbook in the download option to user.

1 solution

It's difficult to say without seeing all of the Macro code (which is probably where the error is occurring)

However, the fact that it's working locally and giving a 'file not found error' on the server makes me think you are using directory locations \ path strings in the Macro that don't exist on the server?

Double check your Macro code, look at all the places where you are referencing a path, e.g C:\Some Path\My Excel Documents\

Do the paths you reference exist on the server? Does the security context the process is executing under on the server have permission to the location?
 
Share this answer
 
Comments
imdarklord 16-Dec-10 7:03am    
Dylan, when i execute the exe manually the new excel file is created in the temp folder that means there is no issue with the path that i have provided.
Dylan Morley 16-Dec-10 7:06am    
OK so possibly due to the security. When running under the ASP.NET account, it may not have rights to certain directories.

Check the directories and make sure the ASP.Net account has Read\Write access to those locations
imdarklord 17-Dec-10 5:50am    
Yes sir, the ASPNET has rights to perform read/write operations to the directory as other reports are also generated and temporarily saved in that particular folder.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900