Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
call excel macro from asp page
Hi
Am new to asp.net programming. I need to call a excel macro from asp page. I got this code from msdn site,. The code compiles but I run I don't see the results of macro execution. I don't get any error. I am calling a simple macro that sets the value of active cell in default sheet to something. Here is the code and macro. Excel.Application m_objExcel = new Excel.ApplicationClass(); m_objExcel.Visible = false; Excel._Workbook wb = m_objExcel.Workbooks.Open(fName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); m_objExcel.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, m_objExcel, new Object[] {"firstmacro"}); wb.Close(false, Missing.Value, Missing.Value); m_objExcel.Workbooks.Close(); m_objExcel.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComO bject (m_objExcel); System.Runtime.InteropServices.Marshal.ReleaseComO bject (wb); wb = null; m_objExcel = null; GC.Collect(); Here is the macro. Public Sub firstmacro() ActiveCell.Value2 = 101 End Sub I made sure the Security settings of macros are set to 'Low'. Please help. thanks very much |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
call excel macro from asp page
Guys
after spending grueling 3 days with this issue I found the solution myself. And I found it a minute after posting the question here.. This is the only change I had to do...asp was running the macro but it wasn't saving the changes in excel. so for wb.close(), i gave 'save' argument as true and it worked. wb.Close(true, Missing.Value, Missing.Value); i see many postings on web for this problem with no solution. here is the solution. have fun. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Call an Access macro from an Excel macro | Excel Discussion (Misc queries) | |||
Excel Macro call Word Macro with Parameters | Excel Programming | |||
Excel vba to call Access Macro | Excel Worksheet Functions | |||
Call Excel Macro in VB.NET | Excel Programming | |||
call .DOC from an Excel VBA macro ? | Excel Programming |