RUN excel macro outside excel
We have some users that download a report in excel through a custom report manager (written in either c# or vb.net) Once they download the r开发者_如何学运维eport they need to copy and paste a macro and run it to format some columns of the excel report.
I have two questions: 1. Can the macro be embedded in excel when they download it?so that they dont have to run it each time.. and the easier option 2. Is there a command which they can run that executes the macro outside excel without them having to create new one each time?
Thanks
You can save the macro in a blanc workbook and refrence the VBA code to the activeworkbook if you asign a shortkey to the macro and hit this shortcut in the genrated workbook, the macro will be excecuted against the generated workbook. Offcourse the workbook with the VBA code has to be opened.
Yes, but they'll always get the message "This workbook contains macros, are you sure you want to open it?".
Yes. The workbook would have a button, which would invoke a VBA macro, which would 'import' the source of the macro from somewhere else and create the Sub/Function on the fly with CodeModule.InsertLines. Hideous, but possible.
Might well be that defining in Auto_Open macro is your solution.
There are ways to avoid the security messages: Have customers lower their security settings, define 192.168.. to be in the trusted zone manually, maybe digitally sign your documents, maybe download the workbook to a trusted location, ...
精彩评论