Accessing and manipulating applications from other applications

You can create a VBA macro that will call another application. It is possible to program a VBA macro to open and change another application at run time. For example, you can create a Quattro Pro object from the WordPerfect VBA Editor. This lets you create a WordPerfect VBA macro that will change a Quattro Pro spreadsheet.


To create a WordPerfect VBA Macro that can manipulate a Quattro Pro spreadsheet

WordPerfect Office btnbacktotopproc Accessing and manipulating applications from other applications
1.
 
Open WordPerfect, and click Tools WordPerfect Office onestep Accessing and manipulating applications from other applications Visual Basic WordPerfect Office onestep Accessing and manipulating applications from other applications Visual Basic Editor.
2.
 
Double-click Project (Document1) in the Project view.
3.
 
Click Tools, choose Reference, enable QuattroPro, and click OK.
Every application has an object. Make sure you reference the right object.
4.
 
Double-click the WordPerfect objects folder in the Project view.
5.
 
Double-click ThisDocument, and type the following lines of code in the Editor box:
Public Sub CreateQPTable()
End Sub
This code will add a new method to the ThisDocument class. Make sure that CreateQPTable is declared public so that you can access this macro from WordPerfect.
6.
 
Type the following lines of code in the CreateQPTable method:
Public Sub CreateQPTable()
Dim myQp as Object
Set myQp = CreateObject(“QuattroPro.PerfectScript”)
If myQp Is Nothing Then
MsgBox “The Quattro Pro Object is invalid”, vbCritical
End If
This code creates a Quattro Pro PerfectScript object. After the object is created, it is tested to determine if memory has been allocated to it. A Message Box will inform you if the object is invalid.
7.
 
Type the following lines of code in the CreateQPTable method:
Public Sub CreateQPTable()
Dim myQp as Object
Set myQp = CreateObject(“QuattroPro.PerfectScript”)
If myQp Is Nothing Then
MsgBox “The Quattro Pro Object does not exist”, vbCritical
End If
'Populate the Quattro Pro document
myQp.FileNew “FileNew”
myQp.SetCellString “B1”, “Jan”
myQp.SetCellString “C1”, “Feb”
myQp.SetCellString “D1”, “Mar”
myQp.SetCellString “A2”, “TVs”
myQp.SetCellString “A3”, “VCRs”
myQp.SetCellString “A4”, “Radios”
End Sub
This code will create a new Quattro Pro document and create an inventory table.

WordPerfect Office note Accessing and manipulating applications from other applications

 
For the purpose of this procedure, a simple inventory table was created in a Quattro Pro document (myQP). You can run this macro from WordPerfect. For testing purposes, make sure that Quattro Pro is open. For more information about VBA, see Microsoft Visual Basic Help in the Visual Basic Editor.

Accessing and manipulating applications from other applications