Running auto macros using Excel.application

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);


Reference: http://revolution-of-web.blogspot.com/


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: