Microsoft VBA IDE

How do I open the VBA IDE?
In the
Graphics
editor, do one of the following:
  • Select
    Edit
    >
    VBA Code
    .
  • In an open display, right-click any empty area and select
    VBA Code
    .
  • In an open display, right-click an object and select
    VBA Code
    .
  • Select
    View
    >
    Visual Basic Editor
    . If you have never used VBA Code to open the VBA editor, there will be no VBA project for the display.
Use the
Microsoft
VBA IDE to write, edit, test run, and debug code. It consists of a project explorer, properties window, and code window.
Use the VBA project explorer to view the VBA projects that are associated with the displays that are open in the Graphics editor. The project explorer is initially displayed in the upper left window of the VBA IDE. A VBA project consists of:
  • an icon labeled
    DisplayCode
    with the name of a graphic display in brackets.
  • a folder below the icon called FactoryTalk View Studio Objects. The folder contains a special Class module named
    ThisDisplay
    that represents the display. This module contains the event handlers for the display and objects on the display.
Use the properties window to edit VBA modules, VBA forms, and objects of VBA forms. This window shows the properties of the item selected in the project explorer and allows them to be edited.
Use the editor in the code window to write, edit, test run, and debug code. At the top of the window there are two drop-down lists. The left contains a list of objects that raise events and the right contains a list of procedures or events for the selected object. The object list always contains an item labeled (General) at the top. When General is selected, the right list contains the procedures (subroutines or functions) that have been defined.
To prevent unnecessary events from being raised to the VBA project, objects that raise events are not automatically added to the object list of the code window for the ThisDisplay class. Initially the object list contains only the General item. To add an object that exposes events to the procedures/events list, right-click the object in the Graphics editor and select
VBA Code
from the context menu, or using the
Property Panel
, change the value of the
ExposeToVBA
property to
VBA Control
.
To add code for an event (that is, to create an event handler), select an event from the procedures/event box. Events with code are shown in bold.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal