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.
 Dim PD As PdCommon.Application
Set PD = CreateObject("PowerDesigner.Application")
'Enter script here
'Once script is finished, release PD object
Set PD = Nothing
If
                    PowerDesigner is currently running, this instance will be used; otherwise a new
                    instance will be launched. If you do not specify a version number, the most
                    recent version is used. To specify a specific version, use the
                    syntax:Set PD = CreateObject("PowerDesigner.Application.version")
PD.ActiveModel
Dim cls as PdOOM.ClassIf your model contains shortcuts, we recommend that you use the following syntax to avoid runtime errors when the target model is closed:
Dim obj as PdCommon.IdentifiedObject
Dim cls as PdOOM.Class Set cls = model.CreateObject(PdOOM.cls_Class)For C# and VB.NET, you can use the following syntax (where PdOOM_Classes is the name of the enumeration):
Dim cls As PdOOM.Class Set cls = model.CreateObject(PdOOM.PdOOM_Classes.cls_Class)For other languages such as JavaScript or PowerBuilder, you have to define constants that represent the objects you want to create. For a complete list of class ID constants, see file VBScriptConstants.vbs in the PowerDesigner OLE Automation directory.
'* 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.