Opening Excel Attachement Using VBA

  • Thread starter Thread starter Google Boy of Company C
  • Start date Start date
G

Google Boy of Company C

Hi

I am creating a system that will email a list if people an Excel
spreadsheet as an attachment which is personalised to them. The
recipient then fills in some data and emails the attachement back to a
set email address. At set intervals my system will scan the Exchange
folder for new emails. I need to be able to open the attachement and
capture the data into an Access database. Most of this I am OK with.
The bit I am unsure about is 1. How can I make sure the attachment is
an Excel spreadsheet before I try and open it using VBA code? 2. How do
I then open the file using VBA?

Can anybody provide code samples or point me in the direction of a good
book on the subject.

Many thanks.
 
To know if it's an Excel worksheet, check the attachment name to see if it ends in .xls.

To open any attachment, you must first save it as a system file. Use the Attachment.SaveAsFile method. After that, you can open the saved file using Excel's automation methods (Application.Workbooks.Open).

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba
 
Back
Top