2 Replies Latest reply on Aug 19, 2014 9:42 PM by Dan Miel

    I am using a macro to check to see if a file exists in the vault.

    Sherry Simon

      If the file exists it copies the file to a folder in the user's c drive. To do this in the past we used DIR to check the directory. However, since upgrading to and implementing EPDM this no longer works. I have tried using the filesystem object but this also does not work. Can someone please assist me in creating a code line in my macro to do this. Here is the code as it currently  stands.

       

              For i = j To j + Selection.Count - 1

              'Do While ActiveSheet.Cells(i, 2) <> ""

             

                  If fsFileSystem.FileExists(PDFfilelocation & Trim(ActiveSheet.Cells(i, 2)) & ".pdf") Then

                      If i = 2 Then

                          PDFFName = "TL_" & Trim(ActiveSheet.Cells(i, 2)) & ".pdf"

                      Else

                          PDFFName = Trim(ActiveSheet.Cells(i, 2)) & ".pdf"

                      End If

                         

                      FileCopy PDFfilelocation & Trim(ActiveSheet.Cells(i, 2)) & ".pdf", "c:\print\pdf\" & PDFFName ' & " " & Trim(ThisForm.txtfrev.Text)

                  Else

                      'MsgBox "There is no PDF for " & Trim(ThisForm.txtfpartno.Text) & " " & Trim(ThisForm.txtfrev.Text)

                      Open "c:\print\PDF\notfound.txt" For Append As #1

                      Print #1, Trim(ActiveSheet.Cells(i, 2)) & ".pdf" '& " " & Trim(ThisForm.txtbom_rev.Text)

                      Close #1

                  End If

                  DWGFName = Trim(ActiveSheet.Cells(i, 2)) & ".dwg"

                  If i = 2 Then

                          DWGFName = "TL_" & Trim(ActiveSheet.Cells(i, 2)) & ".dwg"

                      End If

                  'Mid(DWGFName, Len(DWGFName) - 2, 3) = "DWG"

                  If fsFileSystem.FileExists(DWGFileLocation & Trim(ActiveSheet.Cells(i, 2)) & ".dwg") Then

                      FileCopy DWGFileLocation & Trim(ActiveSheet.Cells(i, 2)) & ".dwg", "c:\print\dwg\" & DWGFName   '& " " & Trim(ThisForm.txtbom_rev.Text)

                  Else

                      'MsgBox "There is no DWG for " & Trim(ThisForm.txtfpartno.Text) & " " & Trim(ThisForm.txtfrev.Text)

                      Open "c:\print\DWG\notfound.txt" For Append As #1

                      Print #1, Trim(ActiveSheet.Cells(i, 2)) & ".dwg" '& " " & Trim(ThisForm.txtfrev.Text)

                      Close #1

                  End If

              'GetSA_PDFs Trim(ActiveSheet.Cells(i, 2)) ', Trim(ThisForm.txtbom_rev.Text)

              'i = i + 1

              Next i

              'Loop

              MsgBox "DONE!" & vbCrLf & vbCrLf & "The files were copied to c:\print." & vbCrLf & "Please see the notfound.txt file for drawings that were not found."

       

      The
      ActiveSheet.Cells(I,2) contain the part name which would be the file name in the vault.  The PDFfilelocation is the directory path where the files are located on the c drive in the vault.