LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 178
Default posting this here cuz the outlook programing group is very inactive...

hopefully with how active you guys are you can help! I apologize in advance for posting an outlook vba question in an excel vba group.

I've got this loop that automatically detects for pdf file attachments in a selected range of email items, saves them to Temp so that I am able to then run a shell to print them. Since sometimes there ARENT pdf attachments, I want to only have the flag status change to complete if the e-mail has a pdf attachment. logically, where I have the flagstatus event occur in my loop makes sense to me, but it only changes the flagstatus for the first item in my selection. Here's to hoping someone smarter than me can figure out what's going on here.

Public Sub SaveandPrintAttachments()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strExePath As String

' Get the path to your My Documents folder
strFolderpath = "c:\temp\"


Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection

' Set the Attachment folder. (Folder must exist.)
strFolderpath = strFolderpath

For Each objMsg In objSelection
Set objAttachments = objMsg.Attachments

lngCount = objAttachments.Count
If lngCount 0 Then

For i = lngCount To 1 Step -1
strFile = objAttachments.Item(i).FileName
If Right(strFile, 3) = "pdf" Then
strFile = strFolderpath & strFile
objAttachments.Item(i).SaveAsFile strFile
'use ShellExecute to open the file
'this may not work with zip extension if you use Compressed folders
ShellExecute 0, "print", strFile, vbNullString, vbNullString, 0
objMsg.FlagStatus = olFlagComplete

End If
Next
End If
Next

ExitSub:

Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trouble posting tothis group Clif McIrvin[_2_] Excel Discussion (Misc queries) 10 April 7th 10 06:11 PM
Set Up to Export Excel group list to Outlook Express Leanne Excel Discussion (Misc queries) 1 November 23rd 07 08:43 AM
the owner of posting should be able to delete the posting Mahendra Excel Discussion (Misc queries) 7 August 8th 05 07:21 PM
Please see posting on 05/04/05 does anyone know how to group post? sra Excel Worksheet Functions 0 May 5th 05 08:12 PM
Programing Outlook using Excel V. Roe Excel Programming 5 July 23rd 04 06:00 PM


All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"