Sharing and Referencing Macros

Consider the following options for macros you want to share:

Choosing Whether to Save Your Macro in a Session or Common Project

Importing or Exporting Macros

Choosing Whether to Save Your Macro in a Session or Common Project

Saving a macro directly to a session document makes it easy for you to run and distribute that macro. To run the macro, you can either open the session document in InfoConnect or reference the document in the Visual Basic Editor.

Saving a macro in the Common project allows you to run the macro from any session document.

Create macros in...


an InfoConnect session document.

(See Understanding VBA Project Components.)

run a macro from a single session document.


reference the macro from another session document. (See Controlling Macro Execution.)

the Common project

run a macro from any session document on the computer.

Importing or Exporting Macros

An additional option for sharing Visual Basic code is to export code module (.bas), class (.cls), and form (.frm) files. InfoConnect users can import these files directly to an InfoConnect project in Visual Basic to add new functionality to session documents without altering existing macros.

Note: You cannot use macro files to run macros that use forms or that call other subroutines, in your Visual Basic Project. For example, any recorded macro will run successfully after it has been exported to a macro file, because all the code in any recorded macro file is contained within a single subroutine. However, let’s say you have two macros: a recorded macro (MacroA), and a second macro (MacroB) which includes a call to MacroA. MacroB would not run correctly after being exported to a macro file, because the code in MacroA is not included in its exported file.

Import Visual Basic files

  1. From Visual Basic Editor, select a project (session document) in the Project Explorer to which you want to import the Visual Basic file, and then choose File > Import File.
  2. Select the file, and then click Open.
    The file appears in the project folder that matches the file type.

Export Visual Basic files

  1. From Visual Basic Editor, in the Project Explorer, select the module, class, or form that you want to export, and then choose File > Export File.
  2. Select a location, and then click Save.