VBA Plug will retrieve the VBA source, save it in a new directory and run Project Analyzer on it.
VBA Plug is a standalone program. It's not a VBA add-in (or plug-in). It does not install itself inside the VBA environment or as an Office menu item. You run the program by clicking the file vbaplug.exe.
After starting VBA Plug, you have 2 alternatives to retrieving your VBA code.
A. Read Office file. Pick up the required document file. VBA Plug opens it in Office and retrieves the VBA code in it. This is the quick and simple option.
Include all referenced VBA projects. Select this checkbox to export all projects referenced by the selected Office file. Leave it unselected to export just one VBA project, the one in the file you opened.
Unfortunately, the A approach doesn't always work. If it fails—due to security options, for example—try approach B.
B. Connect to running application. Run an Office application and open the required documents in it. Switch to VBA Plug and let it connect to Office. VBA Plug will retrieve all open VBA projects. This approach lets you export several projects simultaneously. This is useful when your solution consists of several files that refer to each other. Connecting is also required when your security options disallow programmatic access to the VBA code, or when the VBA project is password protected and you need to supply the password before connecting. Connecting is also a solution when the project in question shows a modal dialog at startup.
Here you select an empty directory for the exported code. You can either select a directory by yourself or let VBA Plug generate a new one automatically. The (Automatic new directory) option will create a new directory and export the files in it. It will not overwrite any existing files.
Location of automatic new directory. By default, the automatic new directory will be under the system's temporary directory. You can select another location with the Output directory command in the File menu. VBA Plug will create new sub-directories under the directory you specify via this dialog.
If you have written something in the Output directory field, you can reset it back to (Automatic new directory) by erasing the field's contents.
retrieves the code and saves it in the output directory. When the export is complete, you can run Project Analyzer and open the exported .vbp or .vbg file in it. You can find the file name in the generated log.
retrieves the code and saves it. When complete, it runs Project Analyzer to analyze the exported code.
The Options menu allows you to control two compiler constants. This is useful if your code uses conditional compilation such as #If Win64 Then
or #If Mac Then
. If your code has neither you can ignore the Options menu.
VBA Plug exports each VBA module as a separate file. In addition, a .vbp project file represents each exported VBA project. When several projects are exported at the same time, a .vbg project group file represents all of them.
File type | Description |
---|---|
.bas | Standard module |
.cls | Class module |
.frm | Code behind a UserForm |
.vbadoc | Code behind a document module |
.vbp | VBA project |
.vbg | Project group (collection of .vbp's) |
The generated files are similar to those of Visual Basic 6.0, although changes do exist. You cannot load the exported projects into VB6 as such since this is not a real VBA-to-VB converter. However, you can load them in Project Analyzer.
In many cases there are several VBA projects open at once. For example, in Word you can have a .doc document and the Normal.dot template. The document can call procedures in the template. VBA projects may also refer to other documents, which are loaded at the same time as the main document.
The "Connect" approach automatically exports all the projects that are currently open in the application in question.
The "Read a file" approach lets you select which projects to export. When you check the box "Include all referenced VBA projects", all the projects that are loaded with the main document file are exported. When you uncheck this box, only the project in the selected file is exported.
If you export several projects, several .vbp project files are created. Each .vbp represents a VBA project (one .vbp per original document file). A .vbg project group file is created that represents all the projects. To fully analyze the generated .vbg project group, you need multi-project analysis, which is a feature of Project Analyzer Enterprise Edition. If you don't have this edition, you can still analyze each .vbp project one at a time.
If opening a file fails, try again via the Connect approach as described above.
Your security options do not allow access to your VBA code. You can enable access by the following procedure in the appropriate Office application:
If this doesn't help, quit all running instances of the Office application. Open up the Windows Task Manager (press Ctrl+Alt+Del). Check the Processes list to verify there are no hidden instances of application running. Sometimes Excel.exe, Visio.exe etc. may stay running even after you close them. End the extra processes, rerun the application, set the Trust access option, then run VBA Plug again.
Use the Connect approach. First open the VBA code in Office and supply your password. Then run VBA Plug and connect to the running application.
The project was not exported. It can happen in 2 cases:
VBA Plug does not support the application version installed on your computer. The version may be too new or too old.
Example: "Host application not supported: Microsoft Excel 5.0." In this case, your Excel version is too old and you need to use a newer version. Solutions:
The Office application required to open the selected document file is probably not installed correctly. You need to VBA Plug on a machine that has the respective Office application installed.
You may have disabled the DCOM Server Process Launcher service. Enable the service it via the Computer Management panel in Windows Administrative Tools. VBA Plug can run without the service, but a VBA Plug user reported that this trick solved error #462 on Windows XP with Office 2003.
Close VBA Plug and restart it. Retry. Office may sometimes return "No VBA project" even when there is a VBA project in the file. Restarting should fix the issue.