B
berkeleydb_user
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.ReleaseComObject (m_objExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject (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
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.ReleaseComObject (m_objExcel);
System.Runtime.InteropServices.Marshal.ReleaseComObject (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