Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call an Access macro from an Excel macro Jason W Excel Discussion (Misc queries) 1 May 1st 08 08:33 PM
Excel Macro call Word Macro with Parameters Bill Sturdevant[_2_] Excel Programming 9 May 24th 07 12:21 AM
Excel vba to call Access Macro ppyxl Excel Worksheet Functions 0 July 6th 06 02:42 PM
Call Excel Macro in VB.NET mimoran Excel Programming 0 January 10th 06 04:11 PM
call .DOC from an Excel VBA macro ? Ayato Excel Programming 1 December 1st 03 11:26 PM


All times are GMT +1. The time now is 01:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"