jags26
09-27-2004, 08:52 PM
Hi...
How can I run an excel macro from asp.net? I could able run the same macro from .net windows form, but could not able to run from asp.net web form. I dont get any error messages too.
Any help is apprecited.
Thank you
Jags
herilane
09-28-2004, 04:29 AM
Welcome to the forum.
What code have you tried? Are you opening the Excel file and then using something like xlApp.Run "mymacroname"?
jags26
09-28-2004, 07:16 AM
Hi Helen,
Thanks for the reply.
This is the code I am trying,same code works well with windows form.
Dim oExcel As New Excel.ApplicationClass
Dim oBook As Excel.WorkbookClass
Dim oBooks As Excel.Workbooks
'Start Excel and open the workbook.
oExcel = Server.CreateObject("Excel.Application")
oExcel.Visible = True
oBooks = oExcel.Workbooks
oBook = oBooks.Open("c:\temp\Book1.xls")
'Run the macros.
oExcel.Run("test")
'Clean-up: Close the workbook and quit Excel.
oBook.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
GC.Collect()
Thanks & any help is appreciated.
Jags