.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

run excel macro from asp page

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
Guys...here is my code. it doesn't give any error when i invoke a simple macro from C#. but i don't see any result. all i'm doing in macro is fill some cells Sub firstmacro() Dim i As Integer For i = 10 To 20 For j = 1 To 1 Cells(i, j) = i + 10 Next j Next i End Sub             Excel.Application m_objExcel = new Excel.ApplicationClass();             m_objExcel.Visible = true;                         Excel.Workbook wb = m_objExcel.Workbooks.Open(fName, 0, true, 5, "", "", true,                 Excel.XlPlatform.xlWindows, "", false, false, 0, true);             //m_objExcel.GetType().InvokeMember("firstmacro", BindingFlags.Public, null, null, null);             //m_objExcel.Run("firstmacro");                 //null, null, null, null, null,     null, null, null, null, null,                 //null, null, null, null, null,     null, null, null, null, null,        

View Complete Post

More Related Resource Links

Create And Run Excel Macro At Runtime in C#

You've been tasked with writing a Windows Form application using the .NET Framework that interacts with Microsoft Excel. If you are new to working with Excel in .NET and are having trouble learning how to format certain cells or cell ranges, then this little tip will come in handy. Rather than scour the internet hoping to find the correct set of constants or method syntax for formatting your spreadsheet, use the built in tools in Excel to write the familiar VBA code for you. Then, you can paste the VBA code generated by Excel into the sample C# code below and run it dynamically at runtime.

automating excel macro using C#

runing a excel macro from C# window application

Saving Document With Column items applied via excel macro

I have an excel macro that pulls data down from columns within worksheets that will take an excel spreadsheet and save it as a PDF file into seperate folders based off criteria set in the files. Getting the files into the proper directory is not the problem i'm having. When the script executes it saves the documents directly to our sharepoint site, but the custom columns A B C D etc are all blank and some are 'required' items which sets the document as checked out until i go into the list and enter the required data. Is there anyway to make this macro export as PDF and set the required data for me in the sharepoint column so it checks the documents in for me? I'm figuring this is a simple set of meta datatags but I don't know the syntax for them and I didn't find anything like this on the forum anywhere else. ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "http://DirectoryStructureHere/corporate%20BoFi/pdfs/" & NewFileName & ".pdf" _ , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=False 'Exports the print area as a PDF document named the new filename "Modified: to sharepoint"

Is there a way in VB.Net to embed a custom user control to a web page based on Word or Excel

Hi Everyone.  I'm looking to create a web page that would be used on a local intranet that would use a custom control based on Word and Excel.  I've used code previously to embed it in a Windows application but wasn't sure if anyone knew of any examples out there on how to embed a custom control into a ASP.Net page.

Connect Excel With ASP.NET Page


Hello everybody.

I am trying to connect Excel document to my web page, but don't know how to do it. Is it possible to state the structure of excel table exactly using Gridview or any other tools or control in web page? These excel document contains class routine of our department. Any suggestion will be very helpful to me.

I have uploaded two sample routines here, so that it may helps you to see what kind of structure I am talking about.

Here is the link :

1. Routine pattern - 1 : download

2. Routine pattern - 2 : download

Excel Render - Print Header on Each Page


Hello Microsoft or Forum Members:


This seems like a simple Microsoft Based Reporting System 101 feature...But I can not find out how to do it (among other things that seem like it should work with Microsoft rendering to Microsoft).


How do I make the SSRS 2005 Header for the Report print on each of the pages in excel once it is rendered from SSRS?


All I want is an answer by MSFT that says "YES" it can be done and how or "No" it is not currently available.


I noticed I am not the only one with this type of simple question:

(see this unanswered post)


How to Embedd excel spreadhseet in Web page ?



I need to embedd an existing excel spreadsheet(with all the macros and functions) in asp.net web page. Basically I just need to put that excel spreadhseet in web page.  I searched internet but all they are telling is to open that excel spreadhsheet or play with that through code in c sharp vb. I just need to put that existing spreadhseet on web so that it can be used by multiple users.  Also, I was wondering if putting that existing spreadsheet will be ale to retain its behaviour ?

I need to know if its possible.

1) Embedding excel object in web page.

2) If its behaviour of existing spreadhsheet will remain as is ?







Can I import and execute a macro into an Excel file from asp.net?


Is it possible to have an .aspx page open an Excel file, import a macro (saved in a .bas text file), and then run it? I've been able to do this in the past from a MS Access application, but I have no idea where to begin with asp.net. 

If you've done this before code examples would be appreciated, or if you know of any articles on this, links to the articles would be appreciated too.


Need help - reading hyperlinked page in excel file using c#


Ok, I understand how to use a connection string object to read excel sheets. What I don't know is how to follow a hyperlink inside excel, grab matching data from the linked page and return it to my database. Essentially, the spreadsheet has two columns:

Title  |  Class#

Class# has the hyperlink which links to an internal web site. The connected page has a course description and any pre-required classes that must be taken before you can take this class. This is where I'm rather stumped as I've not had to do this type of thing before. Any code, links or pointers would be appreciated. Many thanks.

How can I embed a excel file in aspx page?


Dear all,

         we want to embed a xls file with macro in web page, and execute the macro when users click the button in xls file.

i do it by using iframe as following,

<IFRAME WIDTH="75%" HEIGHT="55%" NAME="fframe" SRC="Calculator.xls">
     <FRAME WIDTH="75%" HEIGHT="55%" NAME="fframe" SRC="Calculator.xls">
     <EMBED SRC="Calculator.xls" width=200 height=100>

When I open this web page via IE, it will prompt me to open or save the xls file.

We want IE open it directly, but i do not know how to do it.

Dose someone can help me?

Thank you very much.

Best Regards, 


Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Export Visio Database Table Names to Excel

If you use the Enterprise Architect edition of Microsoft Visio for data modeling regularly, then there is a good chance that at some point you've wanted to export just the table names into Excel. You might want to do this to map logical ERD entities to physical data model tables, track project status by entity, or track overlap between database versions.

Excel Automation in .Net

Excel Automation is a buzz word in both webapps and winapps. In the programming life (like Mr.Anderson neo) I guess almost every one could have come across this word. For others let me go further in detail. Excel Automation is automating some or all of the process involved in creating or updating excel worsheets.

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

display data into GridView from excel sheet

I have to display data from excel sheet into my gridview and also I need to figure out a way to store data into excel files from my web page. I am using C# 3.5, VS 2008.

Export SharePoint List to Excel Spreadsheet Programmatically using C#

In SharePoint applications, Custom Lists are used to store business data and Document Libraries to store the documents. But for data manupulation and analysis, Microsoft Excel provides very rich features as compared to SharePoint Lists. That's why people still loves to work on Microsoft Excel Sheets.

Creating an Excel Spreadsheet programmatically using VB.NET

The Interoperability services make it very easy to work with COM Capable Applications such as Word and Excel. This article reveals using Excel from a managed application. Excel is the spreadsheet component of Microsoft Office 2000. The majority of Excel programmatic functionality is exposed through Automation via the type library Excel9.olb. The intention of this article is to express that a managed application can interrelate with Excel as a COM server.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend