C
Cathy Landry
Hello,
I'm running the following code to print Excel attachments in emails. 2
things are happening. I either get the "File in Use PERSONAL.XLS is locked
for editing" or when I run this on another computer the code completes but
nothing prints. I have the same code printing .tiff attachments ( changed
the Shell program)
Any help would be greatly appreciated!
Public Sub PrintExcelAttachments()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set Inbox =
GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item("Batch Prints")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
' all attachments are first saved in the temp folder C:\Temp.
Be sure to create this folder.
FileName = "C:\Temp\" & Atmt.FileName
Atmt.SaveAsFile FileName
' please change the program folder accordingly if MSExcel is not
installed on drive C:
Shell """C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE ""
/h /p """ + FileName + """", vbHide
Next
'Item.Delete
Next
Set Inbox = Nothing
End Sub
Thank you!
Cathy
I'm running the following code to print Excel attachments in emails. 2
things are happening. I either get the "File in Use PERSONAL.XLS is locked
for editing" or when I run this on another computer the code completes but
nothing prints. I have the same code printing .tiff attachments ( changed
the Shell program)
Any help would be greatly appreciated!
Public Sub PrintExcelAttachments()
Dim Inbox As MAPIFolder
Dim Item As MailItem
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set Inbox =
GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item("Batch Prints")
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
' all attachments are first saved in the temp folder C:\Temp.
Be sure to create this folder.
FileName = "C:\Temp\" & Atmt.FileName
Atmt.SaveAsFile FileName
' please change the program folder accordingly if MSExcel is not
installed on drive C:
Shell """C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE ""
/h /p """ + FileName + """", vbHide
Next
'Item.Delete
Next
Set Inbox = Nothing
End Sub
Thank you!
Cathy