Save Excel Attachment Using VBA

C

Cue

Hi,

I'm trying to save an Excel attachment from an email in Outlook using vba. I
keep getting the error code 'Type Mismatch' for the line with the * next to
it.

Sub SaveAttachments()
Dim myOlapp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myItem As Outlook.MailItem
Dim myAttachment As Outlook.Attachment
'Dim I As Long

Set myOlapp = CreateObject("Outlook.Application")
Set myNameSpace = myOlapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myFolder = myFolder.Folders("ADJUSTMENTS")
*Set myAttachment = myFolder.Items

For Each myItem In myFolder.Items
If myAttachment.FileName = "QAZ.xls" Then
myAttachment.SaveAsFile "C:\MailTest\Att.xls"
End If

Next
End Sub

Can anyone show me what it should be or what I am doing wrong?

Thanks!
 
B

Brian Tillman [MVP-Outlook]

I'm trying to save an Excel attachment from an email in Outlook using vba.

Wrong newsgroup for programming questions. Ask in
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