Hey Guys I am trying to save an Outlook attachment to a file via VBA. My problem is my FOR statement is incorrect. Obj. doesn't support this property or method.
I tried to pattern it after Help from the Microsoft. Of course we all know how abbreviated their help examples are.
Any help would be appreciated, thanx
Trudye
Public Function Get_Attachements()
Dim olApp As Outlook.Application
Dim olnamespace As Outlook.NameSpace
Dim myItem As MailItem
Dim olatt As Attachment
Dim myapp As Excel.Application
Dim InDate As Date
Set myapp = CreateObject("Excel.Application")
Set olApp = CreateObject("Outlook.Application")
Set olnamespace = olApp.GetNamespace("MAPI")
Set myItem = olApp.CreateItem(olMailItem)
Set myAtt = myItem.Attachments
Set olApp.ActiveExplorer.CurrentFolder = _
olnamespace.GetDefaultFolder(olFolderInbox)
InDate = Format(Date, mmddyy)
myItem.Subject = "Compiled_RPM_ " & InDate & ".xls"
For Each myItem In olApp.Items
If myItem.SenderName = "Varela, Angel" Then
For Each olatt In myItem.Attachments
myItem.SaveAsFile "C:\Mdb\DlrIntntPurchase-Notes\" & "RPMNotes.xls" & ".xls"
Next
End If
Next
End Function
I tried to pattern it after Help from the Microsoft. Of course we all know how abbreviated their help examples are.
Any help would be appreciated, thanx
Trudye
Public Function Get_Attachements()
Dim olApp As Outlook.Application
Dim olnamespace As Outlook.NameSpace
Dim myItem As MailItem
Dim olatt As Attachment
Dim myapp As Excel.Application
Dim InDate As Date
Set myapp = CreateObject("Excel.Application")
Set olApp = CreateObject("Outlook.Application")
Set olnamespace = olApp.GetNamespace("MAPI")
Set myItem = olApp.CreateItem(olMailItem)
Set myAtt = myItem.Attachments
Set olApp.ActiveExplorer.CurrentFolder = _
olnamespace.GetDefaultFolder(olFolderInbox)
InDate = Format(Date, mmddyy)
myItem.Subject = "Compiled_RPM_ " & InDate & ".xls"
For Each myItem In olApp.Items
If myItem.SenderName = "Varela, Angel" Then
For Each olatt In myItem.Attachments
myItem.SaveAsFile "C:\Mdb\DlrIntntPurchase-Notes\" & "RPMNotes.xls" & ".xls"
Next
End If
Next
End Function