1 Reply Latest reply on Sep 14, 2015 4:27 PM by Gokan Simsek

    I need a macro to check out latest versions of a list of files from a Workgroup PDM 2014.

    Gokan Simsek

      I need a macro to check out latest versions of a list of files from a Workgroup PDM 2014.

      if I can have the list in a text file that would be great. Is this possible with VBA?

      I'd like to check out a drawing and its model at the same time and copy them to a folder on my PC.

        • Re: I need a macro to check out latest versions of a list of files from a Workgroup PDM 2014.
          Gokan Simsek

          I spent 4 hours for this. I'm posting it so you don't have to. You need to enter your paths info etc

           

          Sub Main()

           

              Dim connection As PDMWConnection

              Set connection = CreateObject("PDMWorks.PDMWConnection")

              connection.Login "username", "password", "PDMserver"

              Dim doc2 As PDMWDocument

           

          Dim dataArray() As String

          Dim i As Integer

           

          Const strFileName As String = "C:\Users\yourusername\Desktop\list.txt"

           

          Open strFileName For Input As #1

          dataArray = Split(Input$(LOF(1), #1), vbLf)

          Close #1

           

          For i = LBound(dataArray) To UBound(dataArray)

           

              dataArray(i) = CleanNonPrintable(dataArray(i))

             

              If dataArray(i) <> "" Then

           

                  Set doc2 = connection.GetSpecificDocument(dataArray(i) & ".SLDPRT")

           

                  On Error Resume Next

                  Value = doc2.TakeOwnership()

           

                  Value = doc2.Save("savetopath")

           

                  Set doc2 = connection.GetSpecificDocument(dataArray(i) & ".SLDDRW")

           

                  On Error Resume Next

                  Value = doc2.TakeOwnership()

           

                  Value = doc2.Save("savetopath")

              End If

           

          Next

             

              connection.Logout

           

          End Sub

           

          ---------------------

          insert what's below into a module.

          -----------------------

          Function CleanNonPrintable(StringIn)

           

              Dim Tmp

              Dim Char

              Dim Value

             

              For i = 1 To Len(StringIn)       'Looping through each character in VarCleanMessageText

                  Char = Mid(StringIn, i, 1)   'Getting a substring of each character, i is the character position, 1 is the length of the substring

                  Value = Asc(Char)                       'Getting the Ascii Value of the character

             

                 If (Value > 31) And (Value < 128) Then  'This is a valid printable character

                     Tmp = Tmp & Char                    'So add it to our Tmp String

                 Else

                     Tmp = Tmp & ""       'Otherwise, we'll add <ASCII VALUE> in brackets to the string Feel free

                                                         'to replace the brackets with whatever you feel necessary

                 End If

              Next                                       'Closing our For Loop and going to the next Character

             

              CleanNonPrintable = Tmp                    'Replacing the original VarCleanMessageText with our new value

           

          End Function