4 Replies Latest reply on Jun 3, 2015 1:24 PM by Jason Parker

    S-061104 – ‘How to modify convert task to use variable value from source file in folder name of output path’

    Jason Parker

      For historical purposes, there is an older thread on this topic located here: Re: Using variable in task output path S-061104

       

      Unfortunately S-061104 is missing from the SWX knowledge base, but it's title reflects what I'm trying to achieve: placing variable values from source file into output path of a file conversion task. I used the thread listed above in conjunction with S-054527 and S-062476 to try and achieve what S-061104 was aiming to document.

       

      I'm attempting to make PartNo (Part Number), xRev (Revision), and Description (Description) available but the only variable that I can pull is Description. I have a difficult time understanding why Description works but the other two do not. S-061104.docx contains my entire task conversion script with additions highlighted; those sections pasted below for convenience.

       

      Placing "MsgBox Value" below "GetVariableValue = Value" only produces a result for Description. I get nothing, not even an empty dialog box, for PartNo and xRev.

      ' ******************************************************************************

      Dim vault As Object

      ' ******************************************************************************

       

      ' ******************************************************************************

      Private Sub LoginToVault()

                    On Error GoTo ErrHand

                    Dim strTempVaultName As String

                    Dim strVaultName As String

                    strTempVaultName = "<VaultPath>"

                    i = Len(strTempVaultName)

                    j = InStrRev(strTempVaultName, "\")

                    strVaultName = Right(strTempVaultName, i - j)

                    Set vault = CreateObject("ConisioLib.EdmVault")

                    vault.LoginAuto strVaultName, 0

       

                    Exit Sub

       

                    ErrHand:

                    If Not vault Is Nothing Then

                                   Dim errname As String

                                   Dim errdesc As String

                                   vault.GetErrorString Err.Number, errname, errdesc

                                   Log ("LoginToVault error" & vbCrLf & errname & vbCrLf & errdesc )

                    Else

                                   Log "Error creating file vault interface."

                    End If

      End Sub

       

      Private Function GetVariableValue(FilePath, VariableName, Configuration)

                    On Error GoTo ErrHand

                    Dim File As Object

                  

                    'Get the interface of the file (and its parent folder)

                    Dim Folder As Object

                    Set File = vault.GetFileFromPath(FilePath, Folder)

                  

                    'Obtain the variable interface

                    Dim pEnumVar As Object

                    Set pEnumVar = File.GetEnumeratorVariable

       

                    Dim Value As Variant

       

                    If pEnumVar.GetVar(VariableName, Configuration, Value) Then

                                   GetVariableValue = Value

                                   MsgBox Value

                    Else

                                   GetVariableValue = ""

                    End If

       

                    Exit Function

                  

                    ErrHand:

                                   Dim ename As String

                                   Dim edesc As String

                                   vault.GetErrorString Err.Number, ename, edesc

                                   Log "GetvariableValue error" & vbCrLf & ename & vbCrLf & errdesc

      End Function

      ' ******************************************************************************

       

      ' ******************************************************************************

                    'Get the vault interface

                    Call LoginToVault

                  

                    'Get Variable Values

                    Dim PartNumberVarValue

                    Dim RevNumberVarValue

                    Dim DescriptionVarValue

                    PartNumberVarValue = GetVariableValue(docFileName, "PartNo", "@")

                    RevNumberVarValue = GetVariableValue(docFileName, "xRev", "@")

                    DescriptionVarValue = GetVariableValue(docFileName, "Description", "@")

      ' ******************************************************************************

       

      ' ******************************************************************************

          convFileName = Replace(convFileName, "<PartNumber>", PartNumberVarValue)

          convFileName = Replace(convFileName, "<RevNumber>", RevNumberVarValue)

          convFileName = Replace(convFileName, "<Description>", DescriptionVarValue)

      ' ******************************************************************************

       

      ' ******************************************************************************

            convFileName2 = Replace(convFileName2, "<PartNumber>", PartNumberVarValue)

            convFileName2 = Replace(convFileName2, "<RevNumber>", RevNumberVarValue)

           convFileName2 = Replace(convFileName2, "<Description>", DescriptionVarValue)

      ' ******************************************************************************

       

      For Reference:

           S-054527 – ‘How to modify convert task to use variable value from source file in output file name’
           S-061104 – ‘How to modify convert task to use variable value from source file in folder name of output path’

           S-062476 – ‘ How to modify convert task to use user name in folder name of output path?’