Using VBScript Macros from the RJS iSeries Office Integrator via the OFCRUNPC Command - Support

Using VBScript Macros from the RJS iSeries Office Integrator via the OFCRUNPC Command

From Support

Jump to: navigation, search

Using VBScript Macros from the RJS iSeries Office Integrator via the OFCRUNPC Command

As of V1.1.57 of the RJS iSeries Office Integrator PC component, users can now their own custom VB Scripting macros via the OFCRUNPC command.

The RJS VBScript Editor must also be installed.

If the iSeries Office Integrator main installer is used to install V1.1.57 or above of the iSeries Integrator PC component, the VB Script Editor component is included in the installed automatically.

Creating Macro Files for use with the RJS iSeries Office Integrator

VBScript Macros can be created with any text editor or with the RJS VB Script Editor program (c:\program files\RJSOFFICE\rjsscripteditor.exe)

Note: When the RJS VB Script Editor is used, the F8 key can be used to step through the MAIN subroutine and test the Vb Script interactively.

Attached is a sample macro file: rjsvbscriptmacrosamples.bas

Running VB Script Commands with the OFCRUNPC command

To run VbScript macros with the OFCRUNPC command the following syntax must be used:

OFCRUNPC PORT(21000) CMD('RJSVBSCRIPT~C:\Program files\rjsoffice\rjsvbscriptmacrosamples.bas~LaunchURL;http://www.rjssoft.com;') OPTION(*OTHER)

P1 - RJSVBSCRIPT tells the office integrator we are running a VB script macro.

P2 - C:\Program files\rjsoffice\rjsvbscriptmacrosamples.bas tells the office integrator the name of the VB macro file

P3 - LaunchURL;http://www.rjssoft.com; is a parameter list for the macro delimited by semicolons (;).


Returning Messages from an OFCRUNPC Macro call to the iSeries Joblog

After a VB Macro has completed if the macro sets the RunVBScript return parameter with some value the value will be returned to the joblog on the iSeries. This value can then be read in a CL program by calling the RCVMSG command and looking for an entry that starts with 215 in the joblog. The DSPJOBLOG command can also be used to review the returned message contents.

Example joblog after OFCRUNPC command has been called where the success of a launched URL is returned:

Object FTPCMD in QTEMP type *FILE deleted.  
 File FTPCMD created in library QTEMP.       
 Member FTP added to file FTPCMD in QTEMP.   
 Object FTPLOG in QTEMP type *FILE deleted.  
 File FTPLOG created in library QTEMP.       
 Member FTPLOG added to file FTPLOG in QTEMP.
 PC Commands Completed.                      
 PC Commands Completed Normally.             
 215 URL was launched.

Testing the Sample Macros in the Attached RJSVBScriptMacros file

1.) Detach the file to C:\Program Files\RJSOFFICE\RJSVBScriptMacroSamples.bas

2.) From the iSeries, run the following command to launch a word document on your PC. This sample assumes you have MS Word installed on your PC and have a document of C:\TEST.DOC on your C: drive.

OFCRUNPC  CMD('RJSVBSCRIPT~C:\Program files\rjsoffice\rjsvbscriptmacrosamples.bas~StartWord;c:\test.doc;') OPTION(*OTHER)

This command passes the RJSVBSCRIPT parm to the OFCRUNPC command along with the macro file name and the semicolon delimited parameter list of "StartWord" to tell which VBScript macro subroutine to run and "C:\test.doc" to tell the macro which word doc to launch.

After the command runs if a value was placed in the RunVBScript parameter, that value can be retreived from the job log via the RCVMSG command or can be displayed with the DSPJOBOG command.

3.) From the iSeries, run the following command to launch a web URL.

OFCRUNPC CMD('RJSVBSCRIPT~C:\Program files\rjsoffice\rjsvbscriptmacrosamples.bas~LaunchURL;http://www.rjssoft.com;') OPTION(*OTHER)

This command passes the RJSVBSCRIPT parm to the OFCRUNPC command along with the macro file name and the semicolon delimited parameter list of "LaunchURL" to tell which VBScript macro subroutine to run and "http://www.rjssoft.com" to tell the macro which URL to launch.

After the command runs if a value was placed in the RunVBScript parameter, that value can be retreived from the job log via the RCVMSG command or can be displayed with the DSPJOBOG command.

RJS VB Script Macros Download

http://downloads.rjssoftware.com/files/rjsoffice/integrator/rjsvbscriptmacrosamples.zip

Personal tools