简体   繁体   中英

Executing a macro in Excel sheet

I would like to execute a macro (VBA Code for formatting the sheet) in an excel sheet that i create from code. The approach I use right now is put the macro in the workbook_open event and open the Excel sheet from code. That applies the formatting and I save it later. But this slows down the process a lot.

I would like to know if there is way I can execute a macro using the DocumentFormat.OpenXml SDK or some other .net class without actually opening the excel file thus improving performance.

I have gone through a lot of internet material , but all in vain. Maybe I am just too much into it that I am just overlooking a very simple solution. Kindly advise.

Thanks

I would like to just point out for reference. The comment from Tim is the answer to this, for anyone looking for an answer. I cannot mark a comment as answer so just re writing it. Will mark it as answer until I find some better way to do it.

You'll have to open the file if you want to format it... – Tim Williams

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM