Macro Basic — Basic Data Exercises

Main Exercises

Purpose: he purpose of this lesson is to learn how to enter object attributes for macros and to insert a document macro into the database. This is not a lesson in creating Visual Basic macros.

Windows:
Document Macro Basic

Entering Object Attributes for Macros

In this exercise, you are going to enter object attributes for object types to be used in the macro code.

  1. Open the Document Macro Basic window and click the Object Attributes for Macros tab.
  2. Create two new rows and enter the following objects.
Object Type Attributes
PlantObject KEYA
Project PROJECT_ID
  1. Save the record (F12).

Note: The Plant Design and Engineering Project functionalities must be available in your system and these object types should be made document aware for them to be displayed. 

Entering Document Macro Blocks

In this exercise, you are going to enter document macro blocks. These blocks of code can then be built together into document macros on the Document Macros tab. This makes it possible to reuse blocks of code. The code blocks in this example are written in Visual Basic, but the application also supports Java script.

  1. Open the Macro Basic tab and click the Document Macros tab.
  2. Create two new rows and enter the following macro blocks (use cut & paste):
Block Name Script
WORD_INIT 'Setup some variables'

Dim sMsg

sMsg = "Congratulations on your first document macro!"

WORD_UPDATE Public Sub View_Word()

  MsgBox sMsg

End Sub

Note: You can open a text editor by double-clicking in the Script field. It may help you when you are creating new macros.

  1. Save your macro blocks (F12).

Creating a Document Macro

In this exercise, you are going to build the blocks that you created in the exercise above into a document macro. This simple macro will display a dialog box when you view a Word document.

  1. Macro Basic window and click the Document Macros tab.
  2. Create a new macro (F5).
  3. Enter the following information in the header:
Application Script 
Language
Process Action Main
Function
Description
Word
(use LOV) 
VBScript View TRAINING_VIEW View_Word Training macro, 
displays dialog box.
  1. Click in the table and create XX new rows.
  2. Select the following macro blocks from the List Of Values (F8):
  1. Save the new macro (F12).

Using a Document Macro

To be certain that this new macro works properly, you are going to run the macro when viewing a document file.

  1. Open the Document Revisions window from the Navigator.
  2. Query for the following:
Document
Class
Document
No
Revision
500  %20 A1
  1. Select the Front Wheel document, revision A1, in the Document Revisions window. Right-click, point to File Operations and then click View Document.
  2. Select Original Document in the Select Document Type To View list and then click OK.
  3. If you have viewed this document before, you will be prompted to overwrite the existing temporary file. If so, click Yes.
  4. In the Choose Macro window, your Training Macro should be automatically selected. Click Run Macro.
  5. If the macro was inserted correctly, a confirmation prompt will be displayed.