I'm trying to use a script I pulled from the forum to autosave my program to a different location, but I can't figure out how to pull the serial number that's input at the beginning of the program into the script to use in the new program name. Does anyone have any insight on this issue?
Edit: Below is a copy of the code I'm trying to use. I'm getting the error "ole automation object does not have a default value" on line 12. I do not have much scripting experience, so I've been piecing together things from the forum.
Sub Main() Dim PCDApp, PCDPartPrograms, PCDPartProgram Set PCDApp = CreateObject("PCDLRN.Application") Set PCDPartPrograms = PCDApp.PartPrograms Set PCDPartProgram = PCDApp.ActivePartProgram Dim Cmds As Object Dim Cmd As Object Set Cmds = PCDPartProgram.Commands Dim sernum As String Set sernum = PCDPartProgram.GetVariableValue("V1") If sernum <> "" Then newname = PCDPartProgram.Path & PCDPartProgram.PartName & "_" & sernum & ".PRG" retval = PCDPartProgram.SaveAs(newname) End If For Each Cmd In Cmds If Cmd.Type = ASSIGNMENT Then If Cmd.GetText(DEST_EXPR, 0) = "SERNO" Then bln = Cmd.PutText("""" + sernum + """", SRC_EXPR, 0) Cmd.ReDraw End If End If Next Cmd ' Cleanup Set PCDPartProgram = Nothing Set PCDPartPrograms = Nothing Set PCDApp = Nothing End Sub