C # calls Excel VBA macros

Source: Internet
Author: User

Recently, a series of work to do the maintenance of the website, so do a lot of support tools. There are VBA in Excel, there are tools for direct C # to do. There are times when you need to perform Excel VBA macros in C #, and sometimes even after you execute a VBA macro, get the return value and then handle it accordingly. For ease of use, I've written a Help class that performs Excel VBA macros. Doing a backup on a blog also helps a friend with similar needs.

The Help class provides only one method: Runexcelmacro

Parameter description:

string Excelfilepath Excel file path

string macroname Macro Name

object[] Parameters Macro parameter Group

Out object Rtnvalue macro return value

BOOL Isshowexcel Whether Excel is displayed when executed

Additional Note: VBA macros need to be written in the following diagram in the module in order to be recognized by this method. Written in ThisWorkbook cannot be identified.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.