Getting Started With Open Plan and VBA

OLE Automation (Object Linking and Embedding) is a key feature of the Windows operating system. It allows various Windows applications (eg Excel, Word etc) to share data and common controls.

Open Plan supports the use of OLE automation which enables budding developers to develop applications that interact with the Open Plan application libraries.

The Open Plan Developers Guide provides a more detailed breakdown on how to make use of the Open Plan object hierarchy which, in summary, comprises of Objects, Collections, Methods and Properties:

  • Objects: Open Plan itself, Projects, Activities, Codes
  • Collections: activity records, barchart views
  • Methods: to add, update, delete information, run processes (eg time analysis)
  • Properties: a field in an activity, number of tasks in a project

 

But how do we get started?

In our previous article Getting Started with Open Plan Add Ins (Getting Started with Open Plan Add Ins) we discuss how to create a new add in menu item and link it to a simple VBS script.

When a user runs the add in, parameters are passed to a script and that script will process the parameters passed to it and provide an output.
In this case, using the OLE libraries, we can define (say) and Excel Macro and grab data via the VBA code.

Our Example

We’re going to build a simple example that grabs the current open project’s name

Lets start by adding a reference to the Deltek Open Plan 8.0 Application Type Library to our project. In the Excel VBA Editor, go to Tools > References and select the library:

references

Ready to Code!

Now that we’ve added a reference to the Open Plan Libraries we can code our way into the back-end of the application.

Lets have a look at some demonstration code:

vbacode

Here we define an object (the application) which enables us to access the object hierarchy of Open Plan.

In fact, page 282 of the Developers Guide outlines why this is important:

object33

By creating a reference to the OPCreateApplication33 object, we’re able to access the various object data structures readily.

We then call the GetObject function which returns a reference to an object (in this case an application that is running). This creates a programmatic instance of Open Plan that we can now access:

vbacode2

By calling the ActiveProject method of the Application object, we’re able to return a string.

When we open the demonstration “CLEAN” project and run our Macro, we see the end result:

ouputexcel

There are endless possibilities to expand the functionality of Open Plan harnessing the quick and easy capabilities of VBA.

What possible creative addons can you think of?

Other recent articles

Full blog index
December 01, 2021
December 01, 2021

Find out how GBA Projects can help your project perform.

Contact us.

Clients

  • 01-santos-logo.jpg
  • 02-bhp-logo-new.jpg
  • 03-hansen-logo.jpg
  • 04-sydney-water.jpg
  • 05-beach-energy.jpg
  • 05-kbr-logo.jpg
  • 06-aurecon-logo.jpg
  • 08-riot-tinto-logo.jpg
  • 09-sa-govt-logo.jpg
  • 10-spotless-logo.jpg
  • 11-built-environs-logo.jpg
  • 12-dyno-logo.jpg
  • 13-sa-power-logo.jpg
  • 14-incitec-logo.jpg
  • 15-electranet-logo.jpg