0

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

PowerUser
  • 11,583
  • 20
  • 64
  • 98
Ron
  • 886
  • 13
  • 39
  • 1
    You'll have to open the file if you want to format it... – Tim Williams Jan 24 '13 at 16:17
  • Thank you for the response. Just trying to educate myself, if i do not put it in the workbook_open event and create a separate function, still I will not be able to execute it from code without opening the file?Thanks again – Ron Jan 24 '13 at 16:19

1 Answers1

1

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

Ron
  • 886
  • 13
  • 39