Getting started in scripting

This page in 2003
Top  Previous  Next

To get started in scripting OAK:

1Get into the VBA development environment. Alt+F11 will do this.
2Use the Tools | References command to find the list of software libaries available for VBA to access.
3Find the entry for the Operis Analysis Kit VBA Type Library in the library and enable it.

VBA references

4Press OK to dismiss the Tools | References dialog.
5Now press F2. That will bring up the Class Browser. If you filter for Operis_OAK, you will find the various methods and properties listed in this help.

 Object browser

6Write the following code in a VBA module

Option Explicit

Sub Main()
  Dim o As Operis_OAK.IOAKAddIn
  Set o = CreateObject("Operis.OAK.Connect")
  Set o.ExcelApplication = Application
 
  o.BuildNameDatabase
End Sub

7Run this and the dialog of OAK's Build name database command will appear.

Build names database dialog

Click OK, and OAK will generate a report of the names that are defined in the currently active workbook. (If, as is likely, that's a new, unused workbook, the report will say that there are no names defined in that workbook.)

8Change the code a little (changes in bold)

Option Explicit

Sub Main()
  Dim o As Operis_OAK.IOAKAPI
  Set o = CreateObject("Operis.OAK.Connect")
  Set o.ExcelApplication = Application
  o.BuildNameDatabase ActiveWorkbook, True, Nothing, False, True, True
End Sub

This time, when the code is run, the same report is generated, but without the dialog appearing. The characteristics of the required report are specified in the program as arguments to the BuildNameDatabase command, rather than manually by the user through the dialog.

See also

Making scripting faster