cancel
Showing results for 
Search instead for 
Did you mean: 

Print power designer data model diagram using VB scripts

velurani
Explorer
0 Kudos

Hi team

Need your help to print a Power designer model diagram using VB script . I checked the meta model help and found the print method is at base diagram level

print()

Sends the display of the diagram to the default printer.

I tried the below code to print the diagram using the script

For Each dia In mdl.AllDiagrams

set Mydiagram= Dia

Mydiagram.print

next

Shows error object does not support property or method . Can anybody help

View Entire Topic
arnaud_laurent
Employee
Employee
0 Kudos

Hello,

If this script is run like this outside PD Desktop then there is no model open yet.
You need
set mdl = PD.OpenModel ("C:\yourPath\yourModel.youExtension")

If you are trying to print the diagrams from Tool > Execute Commands > Edit/Run Script
and a model is open in the client then the following works fine in PD 16.7.7.0 which I tested:

Set mdl = ActiveModel
For Each dia In mdl.AllDiagrams
set MyDiagram = dia
MyDiagram.Print
Next

KR

velurani
Explorer
0 Kudos

Thanks Arnaud

The PD model is opened on desktop before running the below script from the excel

I agree that the below script executes from the execute command from PD application .

Set mdl = ActiveModel
For Each dia In mdl.AllDiagrams
set MyDiagram = dia
MyDiagram.Print
Next

but its not executing from the excel file . I have the model opened , All are fine. I can run the other script to find out the objects and print

Set mdl = ActiveModel

For Each tb In mdl.Entities

Debug.print tb.Name ' I know this print is different . I have shown it for demo

Next

but some how pint diagram is not working from excel . In the execute command it may be using the PD print setting . while executing from the excel , it may not finding the printer setting . something is not working . I feel that some container issue for the print function . Any other solution? Thanks a lot