A friendly Mentor employee pointed out that I needed to include the code for GetLicensedDoc function which was provided earlier in the documentation that I had skipped. There is still an issue with launching Expediton with no errors running this. I'll post the answer as I find the solutions.
Public Function GetLicensedDoc(app)
On Error Resume next
Set GetLicensedDoc = Nothing
' collect the active document
Set docObj = app.ActiveDocument
If (Err) Then
Call app.Gui.StatusBarText("No active document: " & Err.Description,epcbStatusFieldError)
' Ask document for the key
key = docObj.Validate(0)
' Get token from license server
Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
licenseToken = licenseServer.GetToken(key)
Set licenseServer = Nothing
' Ask the document to validate the license token
If (Err) Then
Call app.Gui.StatusBarText("No active document license: " & Err.Description,epcbStatusFieldError)
' everything is OK, return document
Set GetLicensedDoc = docObj
1 of 1 people found this helpful
Yes, the GetLicensedDoc function is included in the PCB Automation Manual.
You can use the Scripting.DontExit property to allow the script to handle events without looping and calling Sleep.
I just noticed that you are only handling the Application Quit event, so you do not need to get and validate the document object.
so simply replace:
' An infinite loop to prevent script from exiting
Do While doNotExit
When I do that the board still doesn't want to open when I double click a pcb file.
Al suggested that I use [Expedition PCB - Document] in my scripts.ini file for my event handler which appears to work pretty nicely so far. I was just using [Expedition PCB] previously.
Scripting.DontExit = True
I was getting an error thrown when I exited Expedition and changing my event handler to use the Scripting.DontExit = True instead of the loop got rid of the error.
Thanks for the help John!