hexagon logo

Scripting Help for auto Save-as

Trying to get going on some scripting and automation. Very new to this so any and all help most appreciated. The following code gives this error :

---------------------------
PC-DMIS Basic Scripting Engine
---------------------------
Error on line: 9 - OLE Automation object does not have a default value
---------------------------
OK
---------------------------

Can someone help me get this simple script running?

Sub Main ()
Dim App As Object
Dim Part As Object
Set App = CreateObject ("PCDLRN.Application")
Set Part = App.ActivePartProgram
Dim Serial As Object
Set Serial = Part.GetVariableValue("V1")
Dim NewName$
NewName = Part.Path & Part.PartName & "_" & Serial & ".PRG"
retval = Part.SaveAs(NewName)
' Cleanup
Set Part = Nothing
Set App = Nothing
End Sub


I believe this code was originally posted in a different (and probably much better) form by VPT.se. I'm trying to learn how to do this sort of thing by modifying it.

Thanks for any help.
Parents
  • ...there are users that don't give a ***** about the serialnumber as well, so don't enforce it to be entered each and every time a program is executed.


    Agreed. Any function like this must be an option. Just as there is now an option to add a print report command that can append an incremental number or string depending on how you set it up. I am simply recommending a Save-as command that could be added the same way. An input comment works just fine for inputing the serial number. My only point is that anything like this that gets added should not be designed so that it will only be able to use a serial number input from the file header. It must be flexible enough to allow for referencing variables and tracefields. PCD2XL currently does not have this flexibility and it is a real pain for us. Operators forget to put the serial number in the header, then we get multiple excel sheets with the same serial number on them and need to go back through the program run log to figure out which part was run when and assign the correct serial number to it. For industires that do require 100% traceability of critical parts (aerospace, Powergen, etc.) this is a big problem.
Reply
  • ...there are users that don't give a ***** about the serialnumber as well, so don't enforce it to be entered each and every time a program is executed.


    Agreed. Any function like this must be an option. Just as there is now an option to add a print report command that can append an incremental number or string depending on how you set it up. I am simply recommending a Save-as command that could be added the same way. An input comment works just fine for inputing the serial number. My only point is that anything like this that gets added should not be designed so that it will only be able to use a serial number input from the file header. It must be flexible enough to allow for referencing variables and tracefields. PCD2XL currently does not have this flexibility and it is a real pain for us. Operators forget to put the serial number in the header, then we get multiple excel sheets with the same serial number on them and need to go back through the program run log to figure out which part was run when and assign the correct serial number to it. For industires that do require 100% traceability of critical parts (aerospace, Powergen, etc.) this is a big problem.
Children
No Data