Opening Excel Attachement Using VBA

  • Thread starter Google Boy of Company C
  • 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.
 
S

Sue Mosher [MVP-Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top