问题
This may be a silly question - I haven't found anything on Google about this. No new programs populate in the task manager when VBE is opened from an Office Application, and I don't see an executable that looks probable. DLL maybe?
回答1:
Some Office applications provide the Run method for the Application class. For example, see Run Excel Macro from Outside Excel Using VBScript From Command Line.
Yes, you can call VBA macro at runtime.
There are applications that don't provide any specific methods for that, for example, Outlook. In that case you can use the late-binding technology (see Type.InvokeMemeber) - see Calling Outlook VBA Macro from outside (VB/VBScript/C#).
回答2:
You can invoke a CommandBarButton
's OnAction
macro as a proxy for Application.Run
.
For details, see this question How can I run a macro from a VBE add-in, without Application.Run?
来源:https://stackoverflow.com/questions/28094070/can-vbe-be-invoked-used-outside-of-an-office-application