VB to save an xlsx outlook attachment as an xls file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • YuffieLM
    New Member
    • Aug 2013
    • 3

    VB to save an xlsx outlook attachment as an xls file

    I am very new to VB and have a simple code in Outlook to save my attachments from Outlook to the drive. I want to link them in Access from the drive but the files are sent in xlsx format and I have Access 2003. So can I edit my Outlook code to save the attachment in xls format?

    Here is the code:

    Code:
    Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
        Dim objAtt As Outlook.Attachment
        Dim saveFolder As String
        Dim dateFormat
        dateFormat = Format(itm.ReceivedTime, "yyyy-mm-dd H-mm")
        saveFolder = "C:\Email Downloads"
        For Each objAtt In itm.Attachments
            objAtt.SaveAsFile saveFolder & "\" & dateFormat & objAtt.DisplayName
        Next
    End Sub
    Many thanks!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    No you cannot, you need to be able to read an xlsx to be able to convert it to another format. Unless you have Excel 2007 and up, you can't read an xlsx, therefore you can't convert it to an xls.

    Comment

    • YuffieLM
      New Member
      • Aug 2013
      • 3

      #3
      Hi,

      Thanks for that. I have Excel 2010 but I'm still on Access 2003 so my issue is getting Access to recognise the file rather than Excel. If that makes sense! I want to automate the process so that the file goes straight from my email into Access ideally.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Then you'll need to automate excel to open the workbook and save it in a new format. If you don't know how to automate an application, we have a tutorial here: http://bytes.com/topic/access/insigh...ion-automation

        Comment

        • YuffieLM
          New Member
          • Aug 2013
          • 3

          #5
          Thank you for your help I'll try that now! :)

          Comment

          Working...