So I found a code that I thought could work for what I am trying to accomplish but I can't figure out where I am going wrong with it. Here is my code so far...
Sub RSAAttachments()
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
If Inbox.Items.Count = 0 Then
MsgBox "There are no messages in the Inbox.", vbInformation, "Nothing Found"
Exit Sub
End If
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
FileName = "C:\Users\daniel.white\Desktop\" & Atmt.FileName
Atmt.SaveAsFile ("9390316")
i = i + 1
Next Atmt
Next Item
If i > 0 Then
MsgBox "I Found " & i & " attached files." & vbCrLf & "I have saved them to the desktop." & vbCrLf & vbCrLf & "have a great day!", vbInformation, "Finished!"
Else
MsgBox "I didn't find any attached files in your mail.", vbInformation, "Finished!"
End If
End Sub
I would like to do the following...
1) Look for an email for the current day with a specific file name
2) From this attachment, take only the worksheets that contain data and add it to an existing workbook
3) Make sure the Name of the worksheet from the attachment is carried over to the new workbook
4) Then tie this into an existing macro to format the worksheet like the rest of the workbook
Does anyone know how I can do this? Can you point me into the direction that will allow me to accomplish this?
I have had some GREAT help from other Forum Users/Gurus and hope I can get some more help now!!!!
Thanks!!!
Dan
Bookmarks