mans.joling

why does this script not work

Discussion created by mans.joling on Jun 18, 2009
Latest reply on Jun 20, 2009 by ed_smith

I try to print a screen to a postscriptfile and i does not work

Here is the code :

 

Option Explicit

' Get the application object
Dim pcbApp
Set pcbApp = GetObject(,"MGCPCB.ExpeditionPCBApplication")

' Get the active document
Dim pcbDoc
Set pcbDoc = pcbApp.ActiveDocument

' License the document
ValidateServer(pcbDoc)

' add a reference to the MGCPCB type library in order to use enums
Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")

' Invoke Idf Import dialog
pcbApp.Gui.ProcessCommand("File->Print")

' Get a reference to this dialog
dim dlgObj
dim buttonObj
Dim retBool,diaObj
' Display the HKP dump dialog by executing the command
retBool = app.Gui.ProcessCommand("File->Print",True)
Set diaObj = app.Gui.FindDialog("Print")
If (retBool = False) Then
Call app.Gui.StatusBarText("Print" + _
                             Err.Description,epcbStatusFieldError)
app.Gui.SuppressTrivialDialogs = False
end if
Set buttonObj = diaObj.FindButton("OK")
If (buttonObj Is Nothing) Then
  Call app.Gui.StatusBarText("Print- OK button not found " + _
                             Err.Description,epcbStatusFieldError)
  app.Gui.SuppressTrivialDialogs = False
  end if
 
Call butObj.Click

 

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Local functions

Private Function ValidateServer(doc)
   
    dim key, licenseServer, licenseToken

    ' Ask Expedition’s document for the key
    key = doc.Validate(0)

    ' Get license server
    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")

    ' Ask the license server for the license token
    licenseToken = licenseServer.GetToken(key)

    ' Release license server
    Set licenseServer = nothing

    ' Turn off error messages.  Validate may fail if the token is incorrect
    On Error Resume Next
    Err.Clear

    ' Ask the document to validate the license token
    doc.Validate(licenseToken)
    If Err Then
        ValidateServer = 0   
    Else
        ValidateServer = 1
    End If

End Function

Outcomes