Microsoft Excel - calling an excel macro from aspx page

Asked By Amrita Gaur
17-Nov-08 02:32 AM

I want to call an excel macro from aspx page to create the cutomized excel reports.

any help.

thnx in advance

re  re

17-Nov-08 02:54 AM
I want to call a excel macro from the aspx page and not pasting a dataset to the excel

use Microsoft.Office.Interop assembly  use Microsoft.Office.Interop assembly

17-Nov-08 03:04 AM

Use Microsoft.Office.Interop assembly to call the macro function in the underlying excel.

For e.g. "mac" is the macro name, and 32 is the value being passed to that macro in the following example. xlApp.Run("mac","32")

For futhure reference, use the following urls:

http://en.allexperts.com/q/Excel-1059/Excel-Macro-C-VB.htm

 

re  re

17-Nov-08 04:10 AM

I am using this code to open an excel from aspx page but unable to open the excel file

 

_mExcelApp = new Excel.Application();

if (_mExcelApp == null)

{

throw (new Exception("Unable to Start Microsoft Excel."));

}

//_mstrXLSFileFullName = XLSFileFullName;

_mExcelApp.Visible = true;

// _mExcelApp.WindowState = Excel.XlWindowState.xlMinimized;

_mWorkbook = _mExcelApp.Workbooks.Open(XLSFileFullName, Type.Missing,

Type.Missing,

Type.Missing,

Type.Missing, Type.Missing,

Type.Missing,

Type.Missing,

Type.Missing, Type.Missing,

Type.Missing,

Type.Missing, Type.Missing,

Type.Missing, Type.Missing);

_mWorkSheet = (Excel.Worksheet)_mWorkbook.Worksheets.Application.ActiveSheet;

//_mWorkSheet.Name = _mstrWorkSheetName;

//_mExcelApp.SheetsInNewWorkbook = 1;

_mWorkSheet.Activate();

reply  reply
17-Nov-08 05:44 AM

Just use this code

RunMacro(oAccess, new object[] { "InsertData" });

 

private void RunMacro(object oApp, object[] oRunArgs)

{

object a= oApp.GetType().InvokeMember("Run",

System.Reflection.BindingFlags.Default |

System.Reflection.BindingFlags.InvokeMethod,

null,oApp, oRunArgs);

string result = a.ToString();

if (result == "1")

{

ClientScript.RegisterStartupScript(this.GetType(), "OnClick", "<script language='javascript'>OpenAlert();</script>");

}

}

Running Macro  Running Macro
17-Nov-08 05:03 PM
Deepak,

could you please explain on how to call your RunMacro method. i.e what are the arguments that I need to pass in.

I have an excel macro that i am trying to call from C#. This is what I am doing

         Excel.Application excelapp = new Excel.Application();
         Excel.Workbook excelBook;
         object missing = Type.Missing;
        excelapp.Workbooks.Open("File1.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
        excelBook = excelapp.ActiveWorkbook;
        excelapp.Visible = true;
        excelapp.Run("Module1.MyMacro", "mymacroparam1", missing, missing, missing, missing, missing, missing,
            missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
            missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
        excelapp.Workbooks.Close();

This doesnt work.

Create New Account
help
How can I make my data show as flashing in Excel? Excel Excel Miscellaneous Discussions Microsoft Excel (1) Excel (1) Application.OnTime (1) Worksheet (1) Workbook (1) Macro (1) VBA (1) Font.ColorIndex (1 if you insist, see Chip Pearson's site for VBA code. http: / / www.cpearson.com / excel / BlinkingText.aspx Gord Dibben MS Excel MVP This was great - thank you. My boss loved it. Now I have another question
Printing Excel Worksheets Excel Is there a possible way to print a double sided worksheet from two separate worksheets? Excel Miscellaneous Discussions Microsoft Excel (1) Worksheets (1) Excel (1) I assume you mean double-sided sheet of paper from two worksheets
VBA to compress photos in an excel worksheets Excel I need to write some VBA code, to compress several photos in my excel worksheets. Is there anyone can help me? Thanks! Excel Miscellaneous Discussions VBA (1) Afb1389213c28977 (1) Gsnu200798 (1) Lnk (1) Gst (1) http: / / groups.google com / group / microsoft.public.excel.programming / browse_thread / thread / afb1389213c28977 / 1201ee9ee3bd3c87?lnk = gst&q = compress+pictures#1201ee9ee3bd3c87 - - Gary''s Student - gsnu200798
How to find exact differences between two worksheets Excel Excel Worksheet Discussions Microsoft Excel (1) Uniques (1) AEC04CCD8AD6 (1) Bliengme (1) Caps (1) Duplicates This site is great for finding Uniques / Duplicates: http: / / www.cpearson.com / excel / Duplicates.aspx PLEASE write your message in this white space next time best wishes - - Bernard V Liengme Microsoft Excel MVP http: / / people.stfx.ca / bliengme remove caps from email keywords: How, to, find, , exact
Is there any option to group Worksheets? Excel Please, let me know if there is any option in Microsoft Excel to Group Worksheets. Excel Miscellaneous Discussions Microsoft Excel (1) Worksheets (1) Hiright (1) Ungroup (1) Chick (1) hi right click any sheet tab