Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can VBA Code Be Run Outside of MS Applications?

I just started to learn VBA. As far as I understood, one uses VBA to write macros in MS-Excel. But I wonder if it the only area of application for VBA. Can it be also used like many other standard languages - like Python, for example.

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

like image 881
Roman Avatar asked Nov 17 '11 17:11

Roman


People also ask

Can VBA be used for programming outside of Excel?

The short answer is yes. You can use VBA in Office applications such as Word, Outlook and PowerPoint as well as Excel. VBA is probably used most often in Excel. And you can control other programs from Excel.

What other applications can VBA be used with?

Visual Basic for Applications runs as an internal programming language in Microsoft Office (MS Office, Office) applications such as Access, Excel, PowerPoint, Publisher, Word, and Visio.

Can VBA control other applications?

1 Answer. Show activity on this post. Excel and VBA can control external applications if they have a COM interface - that is to say, if you can declare the application as an object, create an instance of the object, and see its methods and attributes.

Where do I run VBA code?

You can also run your VBA program from within the VBA editor. Just click the "Play" button in the middle of the menu at the top of the editor and the program will run in Excel.


2 Answers

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

In short, you cannot write a VBA only app that is compiled to an .EXE.

like image 114
Justin Self Avatar answered Sep 18 '22 14:09

Justin Self


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

like image 31
phoog Avatar answered Sep 20 '22 14:09

phoog