AnsweredAssumed Answered

Customizing the PDM convert task so that it only runs in certain circumstances

Question asked by Elisabeth Daley on Apr 25, 2019
Latest reply on May 1, 2019 by Elisabeth Daley

Can anyone help me how to get this customized PDM convert task to return a 'Success' status?  I've edited it so that the main sub reads:


Sub main()


       On Error GoTo Fail :   


    Set FileSystemObj = CreateObject("Scripting.FileSystemObject")

    docFileName = "<Filepath>"


    Dim convertRequested

    convertRequested = 0

    If (convertRequested = 1) Then


   ' Get SW interface object

    Set swApp = Application.SldWorks

    swApp.Visible = True

        Convert docFileName


        Success = True  ' this isn't actually doing anything, trying to figure out how to replace it with something that will cause the task to complete without a failed status

    End If

Exit Sub




    Log "Error while converting file '" & docFileName & "': " & vbCrLf & _

    "An unexpected error occurred while executing the generated script. Script syntax error?" & vbCrLf & _

    "Error number: " & Err.Number & vbCrLf & _

    "Error description: '" & Err.Description & "'" & vbCrLf



In my real application, I'll replace the 'convertRequested = 0' line with some logic, but when I run this simple code, the task fails with a 'no file converted' error.  Which is true, nothing is converted, but that's the correct behavior in this case.  Does anyone know how to change this?