Results 1 to 2 of 2

Thread: [RESOLVED] How to check for file type when using VBA to auto extract attachment from Outlook

Threaded View

  1. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,263

    Re: How to check for file type when using VBA to auto extract attachment from Outlook

    First off: Try to Avoid Goto's!

    This:
    Code:
    JumpHere:
    
    If Dir(stFileName) = "" Then
    objAtt.SaveAsFile stFileName
    Else
    i = i + 1
    stFileName = saveFolder & "\" & i & " - " & objAtt.DisplayName
    Goto JumpHere
    End If
    is replaced with this:
    Code:
    Do While Dir(stFileName)<>""
    i=i+1
    stFileName = saveFolder & "\" & i & " - " & objAtt.DisplayName 
    Loop
    
    objAtt.SaveAsFile stFileName
    For checking specific File-Types: e.g. "test.pdf" returns "pdf"
    Code:
    Public Function GetExtension(ByVal cF As String) As String
       Dim cT As String
       Dim tmpString() as String
    
       cT = StrReverse(cF)
       tmpString=Split(cT,".")
       GetExtension=StrReverse(tmpString(0))
       End If
    End Function
    To check FileSize: FileLen-Function

    Code:
    MsgBox FileLen("c:\test.txt") 'FileSize in Bytes
    Last edited by Zvoni; Sep 5th, 2012 at 01:44 AM. Reason: I made a mistake in a codeline. Corrected.

Posting Permissions

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



Click Here to Expand Forum to Full Width