Find » Education » Tutorial: Creating a macro in Visua...

Tutorial: Creating a macro in Visual Enterprise Software

Understanding How to Write Them

By Paul Turnberg, published Dec 17, 2006
Published Content: 7  Total Views: 6,045  Favorited By: 0 CPs
Embed:  
Rating: 3.0 of 5
First, go to the macros menu, and choose edit. In the field that says “Macro Name” enter the name of the macro.
If you name the macro “OnSave” the macro will trigger automatically when you save the document in the window.
(In customer order entry, the macro would be triggered each time you save, for example)

You will receive a message box telling you the macro does not exist. Click Ok
Click in the “Available fields” drop-down to verify that there are items in the drop down. If there are no entries there, you need to register the VSCRIPT.DLL file on the computer.
You can register the file by getting a copy of it (look in the VMFG install directory) and go to “Start | Run” and type
REGSVR32 C:\VScript.dll

Where C:\ would be the full pathname to the file
The basics of the macro are that you can read and write to fields in the window header using the items in the “Available fields” drop down.
For example, working in the purchase receipt entry window, if we wanted to set the original promise date field = desired ship date field + 3 days, we would simply write
PROMISE_DATE = DESIRED_SHIP_DATE +3

Thus we can read and write date. We can therefore set and verify that data is filled in. To do this, I use a “message” variable that is set to “” at initialization. Then, if the “checks” turn up errors, build on the message. At the end of the macro, display the message. You can alternately stop the order from working using the MACRO_MESSAGE keyword and MACRO_SUCCESS keyword. For example, to check that a contact phone and name is filled in, we would add to the macro as follows.

message = ""
If len(CONTACT_NAME) = 0 then
message = message & "Please enter a contact name." & vbCrlf
End if
If len(CONTACT_PHONE) = 0 THEN
MESSAGE = MESSAGE & "Please enter a contact phone number." & vbCrlf
End If

If message <> "" then
MACRO_MESSAGE = message
MACRO_SUCCESS=FALSE
End If

Did You Know?
You can search for VBScript functions and find a list. These functions will all work within the Visual Enterprise macro window.
Resources
Comments
Type in Your Comments Below - (1000 characters left)
Your name:

Submit your own content on this or any topic. Get started »
Advertisment