com.esri.arcgis.framework
Interface IVbaApplication

All Superinterfaces:
Serializable
All Known Implementing Classes:
Application, Application, Application, Application, IVbaApplicationProxy

public interface IVbaApplication
extends Serializable

Provides access to members that modify the VBA projects in this application.

Remarks

The Application object implements the IVbaApplication interface.

When To Use

The IVbaApplication interface allows you to programmatically insert, remove, and run VBA code without actually opening the Visual Basic Editor. This interface has methods to create a new module, insert code into a specific module, remove a module, and run and macro.

Product Availability

Available with ArcGIS Desktop.


Method Summary
 void createCodeModule(String docName, String moduleName)
          Creates a code module in the specified VBA project.
 void insertCode(String docName, String moduleName, String codeText)
          Inserts code into the specified module.
 void removeCodeModule(String docName, String moduleName)
          Removes a code module from the specified VBA project.
 Object runVBAMacro(String docName, String moduleName, String macroName, Object arguments)
          Runs the specified VBA macro.
 

Method Detail

runVBAMacro

Object runVBAMacro(String docName,
                   String moduleName,
                   String macroName,
                   Object arguments)
                   throws IOException,
                          AutomationException
Runs the specified VBA macro.

Description

docName specifes the name of the VBA project that contains the macro you want to run.

moduleName specifes the name of the module that contains the macro you want to run.

MacroName specifies the name of the macro you want to run.

arguments is a Variant array that represents the arguments that you want to pass into this macro.

Remarks

If the macro is in the current document, docName will be "Project".

If the macro is in the Normal template, docName will be "Normal".

If the macro is in a template, docName will be "TemplateProject".

If you want to pass arguments into this macro you are running, first add the arguments to an array and then use that array for arguments parameter of the RunVBAMacro method.

Product Availability

Available with ArcGIS Desktop.

Supported Platforms

Windows

Parameters:
docName - The docName (in)
moduleName - The moduleName (in)
macroName - The macroName (in)
arguments - A Variant (in)
Returns:
A Variant
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

createCodeModule

void createCodeModule(String docName,
                      String moduleName)
                      throws IOException,
                             AutomationException
Creates a code module in the specified VBA project.

Description

docName specifes the name of the VBA project in which you want to create the module.

moduleName specifes the name of the module that you want to create.

Remarks

If you want to create the module in the current document, docName will be "Project".

If you want to create the module in the Normal template, docName will be "Normal".

If you want to create the module in a template, docName will be "TemplateProject".

Product Availability

Available with ArcGIS Desktop.

Supported Platforms

Windows

Parameters:
docName - The docName (in)
moduleName - The moduleName (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

removeCodeModule

void removeCodeModule(String docName,
                      String moduleName)
                      throws IOException,
                             AutomationException
Removes a code module from the specified VBA project.

Description

docName specifes the name of the VBA project from which you want to remove the module.

moduleName specifes the name of the module that you want to remove.

Remarks

If you want to remove a module from the current document, docName will be "Project".

If you want to remove a module from the Normal template, docName will be "Normal".

If you want to remove a module from a template, docName will be "TemplateProject".

Product Availability

Available with ArcGIS Desktop.

Supported Platforms

Windows

Parameters:
docName - The docName (in)
moduleName - The moduleName (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

insertCode

void insertCode(String docName,
                String moduleName,
                String codeText)
                throws IOException,
                       AutomationException
Inserts code into the specified module.

Description

docName specifes the name of the VBA project that contains the module in which you want to insert code.

moduleName specifes the name of the module in which you want to insert code. This module must already exist in the VBA project.

codeText is a string that represents all the code for the macro.

Remarks

If you want to insert code into a module in the current document, docName will be "Project".

If you want to insert code into a module in the Normal template, docName will be "Normal".

If you want to insert code into a module in a template, docName will be "TemplateProject".

The string for codeText must include all the text for the macro code including the sub procedure declaration and end sub.

Product Availability

Available with ArcGIS Desktop.

Supported Platforms

Windows

Parameters:
docName - The docName (in)
moduleName - The moduleName (in)
codeText - The codeText (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.