(Solved) – How to convert an xls attachment file to xlsx format using VBA in Outlook?

(solved)-–-how-to-convert-an-xls-attachment-file-to-xlsx-format-using-vba-in-outlook?

First, I don’t really work with VBA so please I need a complete solution.

Everyday I receive xls files in Outlook 2016 and I need to :

  • Save the files in a specific path
  • Rename the attachment with a _ and yesterday’s date. Ex: FileName_2020-01-06
  • Convert the file to xlsx format

So far, I added the rule that saves the file to the specific path, and it works.

Now I want to extend the code so it can rename the file and convert it to xlsx format.

Here’s the code I have so far :

    Sub SaveAttachement(Item As Outlook.MailItem)
    Set attachs = Item.Attachments
    For Each attach In attachs
    file = attach.FileName
    attach.SaveAsFile "\FILEPATH" & file
    Next
    End Sub

Can someone help me with this ?

Thank you very much !

Leave a Reply

Your email address will not be published. Required fields are marked *