Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.excel.programming > #109647 > unrolled thread
| Started by | Matthew Dyer <matthew.e.dyer@gmail.com> |
|---|---|
| First post | 2016-11-22 15:05 -0800 |
| Last post | 2016-11-24 06:05 +0000 |
| Articles | 14 — 8 participants |
Back to article view | Back to microsoft.public.excel.programming
posting this here cuz the outlook programing group is very inactive... Matthew Dyer <matthew.e.dyer@gmail.com> - 2016-11-22 15:05 -0800
Re: posting this here cuz the outlook programing group is very inactive... phamhang29753 <phamhang29753@gmail.com> - 2016-11-23 03:07 +0000
Re: posting this here cuz the outlook programing group is very inactive... GS <gs@v.invalid> - 2016-11-23 00:08 -0500
Re: posting this here cuz the outlook programing group is very inactive... Matthew Dyer <matthew.e.dyer@gmail.com> - 2016-11-23 07:10 -0800
Re: posting this here cuz the outlook programing group is very inactive... GS <gs@v.invalid> - 2016-11-23 12:52 -0500
Re: posting this here cuz the outlook programing group is very inactive... Matthew Dyer <matthew.e.dyer@gmail.com> - 2016-11-23 10:54 -0800
Re: posting this here cuz the outlook programing group is very inactive... GS <gs@v.invalid> - 2016-11-23 14:19 -0500
Re: posting this here cuz the outlook programing group is very inactive... aokoa12 <aokoa12@gmail.com> - 2016-11-23 08:36 +0000
Re: posting this here cuz the outlook programing group is very inactive... Tvlebung396 <Tblebsng105@gmail.com> - 2016-11-23 15:03 +0000
Re: posting this here cuz the outlook programing group is very inactive... Tvlebung396 <Tblebsng105@gmail.com> - 2016-11-23 16:05 +0000
Re: posting this here cuz the outlook programing group is very inactive... Claus Busch <claus_busch@t-online.de> - 2016-11-23 22:05 +0100
Re: posting this here cuz the outlook programing group is very inactive... Tslebyng224 <Txlebjng923@gmail.com> - 2016-11-24 00:03 +0000
Re: posting this here cuz the outlook programing group is very inactive... Tslebyng224 <Txlebjng923@gmail.com> - 2016-11-24 03:04 +0000
Re: posting this here cuz the outlook programing group is very inactive... PhunuSEO <PhunuSEO@gmail.com> - 2016-11-24 06:05 +0000
| From | Matthew Dyer <matthew.e.dyer@gmail.com> |
|---|---|
| Date | 2016-11-22 15:05 -0800 |
| Subject | posting this here cuz the outlook programing group is very inactive... |
| Message-ID | <9cbcab3c-cb34-466d-a3a0-5886d311bf6a@googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | phamhang29753 <phamhang29753@gmail.com> |
|---|---|
| Date | 2016-11-23 03:07 +0000 |
| Message-ID | <phamhang29753.127ac728@excelbanter.com> |
| In reply to | #109647 |
cảm ơn bác chia sẻ -- phamhang29753
[toc] | [prev] | [next] | [standalone]
| From | GS <gs@v.invalid> |
|---|---|
| Date | 2016-11-23 00:08 -0500 |
| Message-ID | <o13883$mm5$1@dont-email.me> |
| In reply to | #109647 |
Edit as follows to reset lngCount before looping the messages...
>...
> For Each objMsg In objSelection
> Set objAttachments = objMsg.Attachments
>
lngCount = 0 'reset
> 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
--
Garry
Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
[toc] | [prev] | [next] | [standalone]
| From | Matthew Dyer <matthew.e.dyer@gmail.com> |
|---|---|
| Date | 2016-11-23 07:10 -0800 |
| Message-ID | <9d51be48-768b-4aad-abb4-91cddba25e8c@googlegroups.com> |
| In reply to | #109649 |
Thank you for the advice, but unfortunately only my first selected e-mail item is updating the flag. There are attachments in every selected e-mail, but I only want to 'do stuff' when there is a PDF attachment. I was able to figure out how to save/print the pdf via shell, but adding categories/flagstatuses isn't happening on each e-mail. On Tuesday, November 22, 2016 at 10:09:00 PM UTC-7, GS wrote: > Edit as follows to reset lngCount before looping the messages... > > >... > > For Each objMsg In objSelection > > Set objAttachments = objMsg.Attachments > > > lngCount = 0 'reset > > 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 > > -- > Garry > > Free usenet access at http://www.eternal-september.org > Classic VB Users Regroup! > comp.lang.basic.visual.misc > microsoft.public.vb.general.discussion
[toc] | [prev] | [next] | [standalone]
| From | GS <gs@v.invalid> |
|---|---|
| Date | 2016-11-23 12:52 -0500 |
| Message-ID | <o14kv5$a37$1@dont-email.me> |
| In reply to | #109651 |
> There are attachments in every selected e-mail, but I only want to > 'do stuff' when there is a PDF attachment. I was able to figure out > how to save/print the pdf via shell, but adding > categories/flagstatuses isn't happening on each e-mail. I'm not understanding why you feel a need to update any flags! Your code only processes PDF files and so why do you need to flag it? -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion
[toc] | [prev] | [next] | [standalone]
| From | Matthew Dyer <matthew.e.dyer@gmail.com> |
|---|---|
| Date | 2016-11-23 10:54 -0800 |
| Message-ID | <0fac10d4-d4b1-4200-8471-91505ef30bff@googlegroups.com> |
| In reply to | #109656 |
On Wednesday, November 23, 2016 at 10:52:53 AM UTC-7, GS wrote: > > There are attachments in every selected e-mail, but I only want to > > 'do stuff' when there is a PDF attachment. I was able to figure out > > how to save/print the pdf via shell, but adding > > categories/flagstatuses isn't happening on each e-mail. > > I'm not understanding why you feel a need to update any flags! Your > code only processes PDF files and so why do you need to flag it? > > -- > Garry > > Free usenet access at http://www.eternal-september.org > Classic VB Users Regroup! > comp.lang.basic.visual.misc > microsoft.public.vb.general.discussion Thank you for helping me with this Garry! You've been very very helpful in the past. Not all e-mail items have a PDF attachment, and I'm only looking to print PDF attachments. If there is no pdf attachment, the flag would not be updated to complete thus identifying the item for futher work to be done. If there is a PDF attachment, I want to be able to identify it as having been printed with the Complete checkmark. Hope that helps clarify?
[toc] | [prev] | [next] | [standalone]
| From | GS <gs@v.invalid> |
|---|---|
| Date | 2016-11-23 14:19 -0500 |
| Message-ID | <o14q1i$ucj$1@dont-email.me> |
| In reply to | #109658 |
> On Wednesday, November 23, 2016 at 10:52:53 AM UTC-7, GS wrote:
>>> There are attachments in every selected e-mail, but I only want to
>>> 'do stuff' when there is a PDF attachment. I was able to figure out
>>> how to save/print the pdf via shell, but adding
>>> categories/flagstatuses isn't happening on each e-mail.
>>
>> I'm not understanding why you feel a need to update any flags! Your
>> code only processes PDF files and so why do you need to flag it?
>>
>> --
>> Garry
>>
>> Free usenet access at http://www.eternal-september.org
>> Classic VB Users Regroup!
>> comp.lang.basic.visual.misc
>> microsoft.public.vb.general.discussion
>
> Thank you for helping me with this Garry! You've been very very
> helpful in the past. Not all e-mail items have a PDF attachment, and
> I'm only looking to print PDF attachments. If there is no pdf
> attachment, the flag would not be updated to complete thus
> identifying the item for futher work to be done. If there is a PDF
> attachment, I want to be able to identify it as having been printed
> with the Complete checkmark. Hope that helps clarify?
Thanks for clarifying, Matthew! I don't use OE and so have no idea of
its automation specifics. Makes sense now as to why you need to flag
messages!
So you need to add an 'If..Then' check for the flag setting and only
process those not yet processed. You could simply expand your check for
the filetype...
If Right$(strFile, 3) = "pdf" And _
objMsg.FlagStatus <> olFlagComplete Then
..where you need to set the value for olFlagComplete somewhere so that
your code knows what it is. (I don't see where it's defined in your
routine so I assume it's defined at module level; -otherwise it
persists as zero!)
--
Garry
Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
[toc] | [prev] | [next] | [standalone]
| From | aokoa12 <aokoa12@gmail.com> |
|---|---|
| Date | 2016-11-23 08:36 +0000 |
| Message-ID | <aokoa12.127b0d78@excelbanter.com> |
| In reply to | #109647 |
* [image: http://batdongsanquangninh.vn/images/banners/logo.png]* WEBSITE BATDONGSANQUANGNINH.VN LÃ* WEBSITE HÃ*NG đầU Vá» QUảNG CáO, MUA BáN BấT độNG SảN TạI QUảNG NINH, CHÃ*NH THứC đươC THÃ*NH Láº*P VÃ*O NăM 2012. LÄ©NH Vá»±C HOạT độNG CHÃ*NH Cá»§A CôNG TY LÃ* QUảNG CáO, Tư VấN, MôI GIá»›I, MUA BáN, CHO THUê BấT độNG SảN. Trải qua nhiều năm hoạt động chúng tôi đã ná»— lá»±c vượt qua má»i khó khăn để dần từng bước thay đổi được phương thức quảng cáo vÃ* mua bán truyá»n thống cá»§a ngưá»i dân thÃ*nh phố giúp cho Ngưá»i bán vÃ* Ngưá»i mua rá»… dÃ*ng thá»±c hiện các giao dịch mua bán nhÃ*, đất má»™t cách minh bạch, nhanh chóng. Rút kinh nghiệm qua việc hoaÌ£t động nhiều năm vaÌ€ từ những ý kiến đóng góp cá»§a quý khách, trong thá»i gian tá»›i chúng tôi sẽ ná»— lá»±c hÆ¡n nưa nhằm phát triển Website có thêm những tÃ*nh năng ưu việt, quảng bá rá»™ng khắp hÆ¡n nữa giúp cho các giao dịch được tiến hÃ*nh má»™t cách nhanh chóng. Ra Ä‘á»i xuất phát từ trải nghiệm thá»±c tế cá»§a chÃ*nh ngưá»i sáng láº*p ra Công ty vá»›i mong muốn giúp cho cá»™ng đồng có được thông tin minh bạch mang lại giá trị lợi Ã*ch tốt nhất cho khách hÃ*ng. Äây chÃ*nh lÃ* cÆ¡ sở ná»n tảng để công ty xây dá»±ng phương châm kinh doanh vá»›i mong muốn mang đến sá»± chuyên nghiệp, uy tÃ*n, niá»m tin cho khách hÃ*ng. ::*CáC DịCH Vụ CHÃ*NH*::: - Äăng tin quảng cáo mua bán nhÃ* đất - Äăng banner quảng cáo - Äăng bÃ*i PR quảng bá sản phẩm, dịch vụ bất động sản - Tư vấn, mua bán bất động sản - Môi giá»›i bất động sản - 'bán nhÃ* quảng ninh' (http://batdongsanquangninh.vn) - 'nha dat hạ long' (http://batdongsanquangninh.vn) *::Má»I THôNG TIN đóNG GóP, QUý KHáCH VUI LòNG LIêN Hệ::* *Äịa chỉ : Nguyá»…n Văn Cừ - Hạ Long - Quảng Ninh**Äiện thoại : 0984.690.188**Email : batdongsanquangninh.vn@gmail.com* -- aokoa12
[toc] | [prev] | [next] | [standalone]
| From | Tvlebung396 <Tblebsng105@gmail.com> |
|---|---|
| Date | 2016-11-23 15:03 +0000 |
| Message-ID | <Tvlebung396.127b6fe8@excelbanter.com> |
| In reply to | #109647 |
Matthew Dyer;1627237 Wrote: > 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 Tôi vẫn biết cmt cuối cùng cá»§a tôi không thể được like nhiá»u như thằng cmt đầu tiên, vÃ* nhục nhã hÆ¡n khi cái cmt cuối cùng cá»§a tôi không phải lÃ* cmt cuối cùng, nhưng tôi vẫn tá»± hÃ*o khi được sở hữu nó. -- Tvlebung396
[toc] | [prev] | [next] | [standalone]
| From | Tvlebung396 <Tblebsng105@gmail.com> |
|---|---|
| Date | 2016-11-23 16:05 +0000 |
| Message-ID | <Tvlebung396.127b7df8@excelbanter.com> |
| In reply to | #109647 |
Matthew Dyer;1627237 Wrote: > 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 Vị huynh Ä‘Ã*i nÃ*y vãi tháº*t. Facebook lÃ* nÆ¡i anh hÃ*o võ lâm chÃ*nh phái tÃ* phái há»™i tụ, Bắc có Tiêu Phong, Nam có Má»™ Dung, Äông có HoÃ*ng Äảo Chá»§, Tây có Âu Dương Phong, thiết há»i võ lâm được mấy ngưá»i có cmt bá đạo như huynh? E rằng mấy vị chưởng môn NgÅ© Nhạc Kiếm Phái hoặc tháº*m chÃ* lÃ* Äông Phương Giaó Chá»§ cá»§a Hắc Má»™c Nhai ở táº*n Tây Nguyên đôi khi cÅ©ng phải cúi đầu trước cmt cá»§a huynh. 1 like cho cmt cá»§a huynh, các hạ tâm phục khẩu phục! -- Tvlebung396
[toc] | [prev] | [next] | [standalone]
| From | Claus Busch <claus_busch@t-online.de> |
|---|---|
| Date | 2016-11-23 22:05 +0100 |
| Message-ID | <o15096$n3u$1@dont-email.me> |
| In reply to | #109647 |
Hi Matthew,
Am Tue, 22 Nov 2016 15:05:38 -0800 (PST) schrieb Matthew Dyer:
> 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.
you check that the attachments are pdf files and only pdf files will be
stored and printed. Why do you want to flag?
I woluld store the pdf files and read the file names into an array. When
I am through I print all saved pdf files:
Sub Test()
Dim objOL As Outlook.Application
Dim objNameSpace As Outlook.Namespace
Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objItem As Object
Dim i As Integer, n As Integer
Dim varFiles() As Variant
Dim strFolderpath As String, FN As String
Set objOL = CreateObject("Outlook.Application")
Set objNameSpace = objOL.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderInbox)
Set objItems = objFolder.Items
strFolderpath = "c:\temp\"
For Each objItem In objItems
If objItem.Class = olMail Then
For i = 1 To objItem.Attachments.Count
If Right(objItem.Attachments(i).Filename, 4) = ".pdf" Then
ReDim Preserve varFiles(n)
FN = strFolderpath & objItem.Attachments(i).Filename
objItem.Attachments(i).SaveAsFile FN
varFiles(n) = FN
n = n + 1
End If
Next
End If
Next
'Print all PDF files
For i = LBound(varFiles) To 1
ShellExecute 0, "print", varFiles(i), "", "", 0
Next
End Sub
Regards
Claus B.
--
Windows10
Office 2016
[toc] | [prev] | [next] | [standalone]
| From | Tslebyng224 <Txlebjng923@gmail.com> |
|---|---|
| Date | 2016-11-24 00:03 +0000 |
| Message-ID | <Tslebyng224.127bee79@excelbanter.com> |
| In reply to | #109647 |
Matthew Dyer;1627237 Wrote: > 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 It is in reality a great and helpful piece of info. I'm satisfied that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing. -- Tslebyng224
[toc] | [prev] | [next] | [standalone]
| From | Tslebyng224 <Txlebjng923@gmail.com> |
|---|---|
| Date | 2016-11-24 03:04 +0000 |
| Message-ID | <Tslebyng224.127c18a8@excelbanter.com> |
| In reply to | #109647 |
Matthew Dyer;1627237 Wrote: > 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 I'd constantly want to be update on new content on this site, saved to bookmarks! -- Tslebyng224
[toc] | [prev] | [next] | [standalone]
| From | PhunuSEO <PhunuSEO@gmail.com> |
|---|---|
| Date | 2016-11-24 06:05 +0000 |
| Message-ID | <PhunuSEO.127c42d8@excelbanter.com> |
| In reply to | #109647 |
Matthew Dyer;1627237 Wrote: > 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 bÃ*i viết rất hay. up để bay xa nhé -- PhunuSEO
[toc] | [prev] | [standalone]
Back to top | Article view | microsoft.public.excel.programming
csiph-web