Consulting

Results 1 to 1 of 1

Thread: [SOLVED] If .pdf Contains "Q#" Then Save Elsewhere

  1. #1
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location

    [SOLVED] If .pdf Contains "Q#" Then Save Elsewhere

    How can I add logic to where if fileExtension = ".pdf" or ".PDF" & .FileName contains "Q#" or "Quote" then do something

        fileExtension = Array(".pdf", ".PDF", ".zip", ".ZIP", ".dwg", ".DWG", ".dxf", ".DXF", ".stp", ".STP", "step", "STEP", ".igs", ".IGS", "xlsx", "xlsb", "xlsm")    For j = 1 To olMsg.Attachments.Count
            Set objAtt = olMsg.Attachments(j)
            strName = objAtt.FileName
            For k = 0 To UBound(fileExtension)
                If Right(strName, 4) = fileExtension(k) Then
                    objAtt.SaveAsFile saveFolder & strName
                    Exit For
                End If
            Next k
        Next j
    SOLVED
        fileExtension = Array(".pdf", ".PDF", ".zip", ".ZIP", ".dwg", ".DWG", ".dxf", ".DXF", ".stp", ".STP", "step", "STEP", ".igs", ".IGS", "xlsx", "xlsb", "xlsm")    For j = 1 To olMsg.Attachments.Count
            Set objAtt = olMsg.Attachments(j)
            strName = objAtt.FileName
            For k = 0 To UBound(fileExtension)
                If Right(strName, 4) = fileExtension(k) Then
                    If InStr(strName, "Q #") > 0 Then
                        saveFolder = strFolderpath & "\^Quoting\Quote of Record\"
                        strName = "Old Quote_" & strName
                        objAtt.SaveAsFile saveFolder & strName
                    ElseIf InStr(strName, "Quote") > 0 Then
                        saveFolder = strFolderpath & "\^Quoting\Quote of Record\"
                        strName = "Old Quote_" & strName
                        objAtt.SaveAsFile saveFolder & strName
                    Else
                    objAtt.SaveAsFile saveFolder & strName
                    End If
                    Exit For
                End If
            Next k
        Next j
    Last edited by VBE313; 01-02-2020 at 07:52 AM.

Posting Permissions

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