Skip to Content
Author's profile photo dirk jaeckel

Comfortable use of VB-Scripting with Powerdesigner

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!!!
    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.



PS: see for some more information on VBS vs. VBA (OLE Automation)

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo bruce daly
      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. 🙂

      Author's profile photo dirk jaeckel
      dirk jaeckel
      Blog Post Author

      welcome bruce 😉

      Author's profile photo Former Member
      Former Member

      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).

      Author's profile photo dirk jaeckel
      dirk jaeckel
      Blog Post Author

      I agree with You 100%, it is always to determine what is your final goal to reach.

      Author's profile photo Anirudhan Velur
      Anirudhan Velur

      Nice Article for starters like me. Thanks