hexagon logo

Partprograms.open scripting error

Ok so I have stolen some code from here on using a script to open a program and run it, then closes the program. It runs and works perfectly... UNTIL I try to make the filepath variable, such as ("C:\Users\Public\Desktop" + strID ) so that I can use a barcode scanner to input the last bit of filepath into the script and execute that way. I keep getting an error message on the PCDpartprogams.open line stating "wrong number of dimensions". Any ideas?


Found this in my repository...


Dim PCDApp, PCDPartPrograms, PCDPartProgram

Set PCDApp = CreateObject("PCDLRN.Application")
Set PCDPartPrograms = PCDApp.PartPrograms

PCDApp.Visible = True
PCDPartPrograms.Open "Z:\test1.PRG", "CMM1"

Set PCDPartProgram = PCDApp.ActivePartProgram

'msgbox "This will start the execution of the partprogram!"
PCDPartProgram.Execute

' PC-DMIS executes the partprogram

PCDPartProgram.Close

' PC-DMIS closes and saves the partprogram

PCDPartPrograms.Open "Z:\test2.PRG", "CMM1"

Set PCDPartProgram = PCDApp.ActivePartProgram

'msgbox "This will start the execution of the partprogram!"
PCDPartProgram.Execute

' PC-DMIS executes the partprogram

PCDPartProgram.Close

' PC-DMIS closes and saves the partprogram

' Cleanup
Set PCDPartProgram = nothing
Set PCDPartPrograms = nothing
Set PCDApp = nothing




This should (in theory) open "test1.prg", execute it, close and save and then open "test2.prg", execute it, close and save.
Parents
  • The code is as follows.

    Sub main(strID As String)
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Dim Fpath As String
    Fpath= "L:\CUSTOM_GLOBAL_PROGRAMS_\" + strID
    
    MsgBox Fpath
    'MsgBox To verify filepath is correct
    PCDApp.Visible = True
    PCDPartPrograms.Open Fpath, "CMM1"
    
    Set PCDPartProgram = PCDApp.ActivePartProgram
    
    'MsgBox "This will start the execution of the partprogram!"
    PCDPartProgram.Execute
    
    ' PC-DMIS executes the partprogram
    
    PCDPartProgram.Close
    
    ' PC-DMIS closes And saves the partprogram
    
    'PCDPartPrograms.Open "Z:\test2.PRG", "CMM1"
    
    'Set PCDPartProgram = PCDApp.ActivePartProgram
    
    'MsgBox "This will start the execution of the partprogram!"
    'PCDPartProgram.Execute
    
    ' PC-DMIS executes the partprogram
    
    'PCDPartProgram.Close
    
    ' PC-DMIS closes And saves the partprogram
    
    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub
Reply
  • The code is as follows.

    Sub main(strID As String)
    Dim PCDApp, PCDPartPrograms, PCDPartProgram
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Dim Fpath As String
    Fpath= "L:\CUSTOM_GLOBAL_PROGRAMS_\" + strID
    
    MsgBox Fpath
    'MsgBox To verify filepath is correct
    PCDApp.Visible = True
    PCDPartPrograms.Open Fpath, "CMM1"
    
    Set PCDPartProgram = PCDApp.ActivePartProgram
    
    'MsgBox "This will start the execution of the partprogram!"
    PCDPartProgram.Execute
    
    ' PC-DMIS executes the partprogram
    
    PCDPartProgram.Close
    
    ' PC-DMIS closes And saves the partprogram
    
    'PCDPartPrograms.Open "Z:\test2.PRG", "CMM1"
    
    'Set PCDPartProgram = PCDApp.ActivePartProgram
    
    'MsgBox "This will start the execution of the partprogram!"
    'PCDPartProgram.Execute
    
    ' PC-DMIS executes the partprogram
    
    'PCDPartProgram.Close
    
    ' PC-DMIS closes And saves the partprogram
    
    ' Cleanup
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub
Children
No Data