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
  • Hi,

    Yeah you'd need VB6 - don't know if you can get it any more.

    The other option would be to turn to .net, you can get the express versions free, but it's a bit more tricky to get your head round -if you do venture down this road there's not a good package & deployment solution in there (as there was with vb6), instead get "Inno Setup5" which is both free and excellent.


    In answer to your question about "Boolean =" I think you can instead of

    retval = part.saveas(path)

    simply say..

    part.saveas path

    Note you drop the parenthesis()
    ..or at least in in VB6 you can.
Reply
  • Hi,

    Yeah you'd need VB6 - don't know if you can get it any more.

    The other option would be to turn to .net, you can get the express versions free, but it's a bit more tricky to get your head round -if you do venture down this road there's not a good package & deployment solution in there (as there was with vb6), instead get "Inno Setup5" which is both free and excellent.


    In answer to your question about "Boolean =" I think you can instead of

    retval = part.saveas(path)

    simply say..

    part.saveas path

    Note you drop the parenthesis()
    ..or at least in in VB6 you can.
Children
No Data