Results 1 to 7 of 7

Thread: How to target just .XLS extension and not implicitly .XLSX ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Hello
    Thanks for your reply.

    It works !


    Quote Originally Posted by gmayor View Post
    The right function only reads the last four characters. The last four characters of the xlsx file are xlsx and not .xls
    It is easy enough to demonstrate. Select a message and run the test macro below

    Sub Test()
    Dim olMsg As MailItem
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        CheckAttachments olMsg
    lbl_Exit:
        Exit Sub
    End Sub
    
    
    Sub CheckAttachments(olItem As MailItem)
    Dim objAtt As Attachment
        For Each objAtt In olItem.Attachments
            MsgBox Right(UCase(objAtt.fileName), 4)
            If Right(UCase(objAtt.fileName), 4) = ".XLS" Then
                MsgBox objAtt.fileName
            End If
        Next objAtt
    lbl_Exit:
        set objAtt = Nothing
        Exit Sub
    End Sub
    Last edited by johngalvin; 10-05-2019 at 01:21 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
  •