Results 1 to 3 of 3

Thread: PDF Function

  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The following function searches for PDF files in a specified folder beginning with the job number [strPDF5 = Left(Me.txtEst, 5)]

    An example of the PDF file name could be 12345-est.pdf, 12345-int.pdf etc.

    I want the code to only locate PDF's with the string "Meth" within it's name.
    example: 12345-est.pdf, 12345-int.pdf, 12345-Meth.pdf

    Can the following code be tweaked to do this?

    Private Function FetchPDF()
    Dim i As Integer
    Dim strFilePDF As String
    Dim strErrorPDF As String

    Pdf1.Visible = True
    Dim strPDF5 As String
    On Error GoTo ErrHandler

    ' Get Left5
    strPDF5 = Left(Me.txtEst, 5)
    strFolderPDF = "L:\MMPDF\ConsoleFiles\" & Me.txtEst & "\"
    Erase arrFileNamesPDF
    i = 0
    ' Get PDF files in strFolder whose names begin with strPDF5
    strFilePDF = Dir(strFolderPDF & "\" & strPDF5 & "*.pdf")
    strErrorPDF = "L:\MMPDF\Utilities\PDFViewer.pdf"
    ' Loop through files
    Do While strFilePDF <> "" And i < 127
    Me.lstArch.AddItem strFilePDF
    i = i + 1
    arrFileNamesPDF(i) = strFilePDF
    strFilePDF = Dir

    Loop
    intFileCountPDF = i
    If intFileCountPDF < 1 Then
    intNumberOfPDF = 0
    Me.AcrobatPath = strErrorPDF
    Me.Pdf1.LoadFile Me.AcrobatPath
    Exit Function
    Else
    intNumberOfPDF = 1
    End If
    FillPDFS 1
    Exit Function

    ErrHandler:
    MsgBox Err.Description, vbCritical, "Error"
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Hi Dave,

    Change the line

    strFilePDF = Dir(strFolderPDF & "\" & strPDF5 & "*.pdf")

    to

    strFilePDF = Dir(strFolderPDF & "\" & strPDF5 & "*Meth*.pdf")

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Hans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •