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


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Running auto macros using Excel.application

Posted By:nishithraj       Posted Date: December 02, 2009    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  
 

Macros can generate dyanamically run into a work book by using the Microsoft.Office.Interop.Excel Component.

But if the security level is low there is no option to make it as high through coding.
That's the prevention done intentionally by microsoft to avoid the spread of viruses through the MS Office softwares.

Following is the code for running an macro in a workbook.

// Run the named VBA Sub that we just added.             objWb.RunAutoMacros(Microsoft.Office.Interop.Excel.XlRunAutoMacro.xlAutoOpen);            objWb.Application.Run("SheetName", Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value, Missing.Value,                                Missing.Value, Missing.Value, Missing.Value);

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

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