OLE Automation and Add-Ins

OLE Automation provides a way to communicate with PowerDesigner from another application using the COM architecture. You can write a program using any language that supports COM, such as Word or Excel macros, VB, C++, or PowerBuilder.You can create executables that call PowerDesigner or add-ins that are called by PowerDesigner.

VBScript programs that run from within PowerDesigner and OLE Automation programs are very similar, but OLE requires you to work through a PowerDesigner application object, and to use stronger typing. You must: This script is launched from outside PowerDesigner, creates an instance of the PowerDesigner Application object, and then uses it to create two OOMs through OLE Automation:
'* Purpose:  This script displays the number of classes defined in an OOM in the output window.
Option Explicit
' Main function
Sub VBTest()
 ' Defined the PowerDesigner Application object
 Dim PD As PdCommon.Application
 ' Get the PowerDesigner Application object
 Set PD = CreateObject("PowerDesigner.Application")
' Get the current active model
 Dim model As PdCommon.BaseModel
 Set model = PD.ActiveModel
 If model Is Nothing Then
  MsgBox "There is no current model."
 ElsIf Not model.IsKindOf(PdOOM.cls_Model) Then
  MsgBox "The current model is not an OOM model."
 Else
  ' Display the number of classes
  Dim nbClass
  nbClass = Model.Classes.Count
  PD.Output "The model '" + model.Name + "' contains " + CStr(nbClass) + " classes."
' Create a new OOM
  Dim model2 As PdOOM.Class
  Set model2 = PD.CreateModel(PdOOM.cls_Model)
  If Not model2 Is Nothing Then
   ' Copy the author name
   model2.Author = Model.Author
   ' Display a message in the output window
   PD.Output "Successfully created the model '" + model2.Name + "'."
  Else
   MsgBox "Cannot create an OOM."
  End If
 End If
' Release the PowerDesigner Application object
 Set PD = Nothing
End Sub

OLE Automation samples for different languages are provided in the OLE Automation directory within your PowerDesigner installation directory.