Can VBA code run outside of MS applications?

I just started to learn VBA. As I understand it, one uses VBA to write macros in MS-Excel. But I am wondering if this is the only application area for VBA. Can it also be used, like many other standard languages ​​- for example, Python.

If so, how can I compile a VBA program? Should it be compiled? How can I run such a VBA program?

+4
source share
5 answers

VBA compiled into p-code. P-code is an intermediate language that requires additional execution time to execute. This runtime is hosted by most Microsoft Office applications (including various non-Microsoft applications).

In short, you cannot only write a VBA application that is compiled into .EXE.

+6
source

To create a stand-alone VBA-like program, you will need to use Visual Basic 6 or earlier. The successor to Visual Basic 6, of course, is VB.NET, which is a completely different animal.

+1
source

A VBA license can be licensed, and in the office where VBA is used, there are quite a few products from pproduct. MS is no longer issuing new licenses. Non-MS VBA implementations exist, for example, from Summit software. In any case, you need to have your own product, which will host VBA.

+1
source

A notable application that supports VBA is AutoDesk AutoCAD. It licenses the VBA runtime and has its own object model.

+1
source

If you do not compile the program ahead of time (in the Visual Basic editor, click "Debug β†’" Compile "), Microsoft Office will compile it at run time. You really have to compile often, because that is how you find compilation errors.

How you launch the VBA application depends entirely on how you configured it to run. For example, in Excel, you can run Workbook_Open your code when you open the workbook or create custom menus that users click to run the code. In Access, you can set the form to display when you open the database or create an autoexec macro that will run when the database is opened. etc. etc.

Like someone else said above, you cannot create .exe VBA files. The code must run in a Microsoft Office application.

-1
source

Source: https://habr.com/ru/post/1381752/


All Articles