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
  • I vaguely recall having a similar incident. I had to split the strID variable into only having the name and adding + ".prg" into the assignment for my vbs to work.

    Edit: After looking at your msgbox, I'm thinking it might not like all the . in the file name. Could be misreading the extension. Try changing to _ and see if it works?
Reply
  • I vaguely recall having a similar incident. I had to split the strID variable into only having the name and adding + ".prg" into the assignment for my vbs to work.

    Edit: After looking at your msgbox, I'm thinking it might not like all the . in the file name. Could be misreading the extension. Try changing to _ and see if it works?
Children
No Data