Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2023, 02:02 AM
JamesMWood JamesMWood is offline Reverse collection items? Windows 10 Reverse collection items? Office 2021
Novice
Reverse collection items?
 
Join Date: May 2022
Posts: 25
JamesMWood is on a distinguished road
Question Reverse collection items?

Hiya



Is there any way to reverse the order that attachments are reattached to my email? Excerpt:

If olItem.Attachments.Count > 0 Then
For i = olItem.Attachments.Count To 1 Step -1
olAtt = olItem.Attachments(i)
sName = olAtt.FileName
If sName Like "*.pdf" Then
sName = Replace(olAtt.FileName, "%20", " ") 'Removes %20 from file names
olAtt.SaveAsFile(sPath & sName)
cNames.Add(sPath & sName)
olAtt.Delete()
End If
Next i

For i = 0 To cNames.Count
olItem.Attachments.Add(cNames(i))
Kill(cNames(i))
Next i

End If
Reply With Quote
  #2  
Old 02-02-2023, 08:29 AM
JamesMWood JamesMWood is offline Reverse collection items? Windows 10 Reverse collection items? Office 2021
Novice
Reverse collection items?
 
Join Date: May 2022
Posts: 25
JamesMWood is on a distinguished road
Default

No worries, figured out another way around my particular issue!

Thanks
Reply With Quote
  #3  
Old 02-02-2023, 10:36 PM
gmayor's Avatar
gmayor gmayor is offline Reverse collection items? Windows 10 Reverse collection items? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Instead of
Code:
For i = 0 To cNames.Count
use
Code:
For i = cNames.Count to 0 step -1
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 02-03-2023, 01:31 AM
JamesMWood JamesMWood is offline Reverse collection items? Windows 10 Reverse collection items? Office 2021
Novice
Reverse collection items?
 
Join Date: May 2022
Posts: 25
JamesMWood is on a distinguished road
Default

Thank you very much, that really helps!
Reply With Quote
Reply

Tags
collection, reverse

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
outlook vba - setting reference to subfolder, sometimes no folder items in collection travb81 Outlook 4 08-15-2023 04:07 AM
Looping backwards through a 'For Each' collection ThinAirDesigns Project 1 05-02-2019 02:16 PM
Deleting items in folders doesnt send them to deleted items! marshy365 Outlook 0 07-29-2016 03:19 AM
site collection is inaccurate dbsoccer51 Misc 0 12-02-2015 03:30 PM
Outlook 2007 Saved sent items list only holds the last ten items david.peake Outlook 0 06-01-2010 07:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft