Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #109647 > unrolled thread

posting this here cuz the outlook programing group is very inactive...

Started byMatthew Dyer <matthew.e.dyer@gmail.com>
First post2016-11-22 15:05 -0800
Last post2016-11-24 06:05 +0000
Articles 14 — 8 participants

Back to article view | Back to microsoft.public.excel.programming


Contents

  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

#109647 — posting this here cuz the outlook programing group is very inactive...

FromMatthew Dyer <matthew.e.dyer@gmail.com>
Date2016-11-22 15:05 -0800
Subjectposting 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]


#109648

Fromphamhang29753 <phamhang29753@gmail.com>
Date2016-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]


#109649

FromGS <gs@v.invalid>
Date2016-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]


#109651

FromMatthew Dyer <matthew.e.dyer@gmail.com>
Date2016-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]


#109656

FromGS <gs@v.invalid>
Date2016-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]


#109658

FromMatthew Dyer <matthew.e.dyer@gmail.com>
Date2016-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]


#109659

FromGS <gs@v.invalid>
Date2016-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]


#109650

Fromaokoa12 <aokoa12@gmail.com>
Date2016-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
hoạt động nhiều năm và 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]


#109652

FromTvlebung396 <Tblebsng105@gmail.com>
Date2016-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 =
> &quot;c:\temp\&quot; Set objOL =
> CreateObject(&quot;Outlook.Application&quot;) 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 &gt; 0 Then For i = lngCount To 1 Step -1 strFile =
> objAttachments.Item(i).FileName If Right(strFile, 3) = &quot;pdf&quot;
> Then strFile = strFolderpath &amp; 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, &quot;print&quot;, 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]


#109653

FromTvlebung396 <Tblebsng105@gmail.com>
Date2016-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 =
> &quot;c:\temp\&quot; Set objOL =
> CreateObject(&quot;Outlook.Application&quot;) 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 &gt; 0 Then For i = lngCount To 1 Step -1 strFile =
> objAttachments.Item(i).FileName If Right(strFile, 3) = &quot;pdf&quot;
> Then strFile = strFolderpath &amp; 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, &quot;print&quot;, 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]


#109660

FromClaus Busch <claus_busch@t-online.de>
Date2016-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]


#109662

FromTslebyng224 <Txlebjng923@gmail.com>
Date2016-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 =
> &quot;c:\temp\&quot; Set objOL =
> CreateObject(&quot;Outlook.Application&quot;) 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 &gt; 0 Then For i = lngCount To 1 Step -1 strFile =
> objAttachments.Item(i).FileName If Right(strFile, 3) = &quot;pdf&quot;
> Then strFile = strFolderpath &amp; 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, &quot;print&quot;, 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]


#109666

FromTslebyng224 <Txlebjng923@gmail.com>
Date2016-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 =
> &quot;c:\temp\&quot; Set objOL =
> CreateObject(&quot;Outlook.Application&quot;) 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 &gt; 0 Then For i = lngCount To 1 Step -1 strFile =
> objAttachments.Item(i).FileName If Right(strFile, 3) = &quot;pdf&quot;
> Then strFile = strFolderpath &amp; 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, &quot;print&quot;, 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]


#109668

FromPhunuSEO <PhunuSEO@gmail.com>
Date2016-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 =
> &quot;c:\temp\&quot; Set objOL =
> CreateObject(&quot;Outlook.Application&quot;) 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 &gt; 0 Then For i = lngCount To 1 Step -1 strFile =
> objAttachments.Item(i).FileName If Right(strFile, 3) = &quot;pdf&quot;
> Then strFile = strFolderpath &amp; 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, &quot;print&quot;, 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