Skip to Content

As you gettin started using the scripting engine PD provides …

.. you have only a simple code window under the menu Tools>Execute Commands>Edit/Run Script

For myself, since ever  a MS-Access developer, i found it more comfortable to use the VBA Editor of Access 2007 (or any other version).

To do so, you need one important Step in Access, that is loading all the PD libaries, so you can use CODE-Completion !!!

Just open Extras/Libaries

and then select/import them all:screen2.PNG

As you can find elsewhere in the PD-documentation, the code in VBA differs slightly from VBS, but thats worth the step πŸ˜‰

here are some starter functions you might always use:

Option Compare Database
Option Explicit
Dim pd_App As PdCommon.Application
Dim InputModel As PdEAM.Model  ' change here as needed to CDM or PDM !
Dim STList, PDMList

'
'  opens the Application PD and the Model YOURMODELNAME only if not loaded already!!!
'
Sub initEAModel(YOURMODELNAME)
    If pd_App Is Nothing Then
        Set pd_App = New PdCommon.Application
    End If
   
   
    If InputModel Is Nothing Then
        Set InputModel = pd_App.OpenModel(YOURMODELNAME)
    End If


End Sub

With VBA in Access ( also Excel or Word)  you have debugging and watch/inspect available, you can typequalify the variables (VBS supports only VARIANT) and so you have code completion.

Enjoy

DJ

PS: see http://scn.sap.com/docs/DOC-44233 for some more information on VBS vs. VBA (OLE Automation)

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. bruce daly

    Thanks Dirk – I will give this a try as I am finding it a bit challenging on the scripting side of things. Keep up the good work. πŸ™‚

    (0) 
  2. PΓ©ter Michaleczky

    There are pros and cons beside scripting in a different place then PD.

    I had a project last year where I wrote a complex Excel import and analysis to create and update EAM models. I started in Excel VBA and soon I realized there are significant differences between VBA and VBScript. Finally I migrated back the whole code to PD as VBScript, because in this case I was able to integrate the routines into the model itself (e.g. create custom user interfaces, dialogs, menus).

    (0) 

Leave a Reply