PDA

View Full Version : [SOLVED] If .pdf Contains "Q#" Then Save Elsewhere



VBE313
01-02-2020, 07:37 AM
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