Save Excel Attachment Using VBA

Status
Not open for further replies.
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!

Cue
 

Brian Tillman

Senior Member
"Cue" <Cue> wrote in message

news:A97EA7E6-B443-43C7-A38F-DD6E930A6565@microsoft.com...


> 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

--
 
C

Cue

Thanks Brian. Will do...

Cue

"" wrote:


> "Cue" <Cue> wrote in message
> news:A97EA7E6-B443-43C7-A38F-DD6E930A6565@microsoft.com...
>
> > 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
> >

> .
>
 
Status
Not open for further replies.
Top