Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 02-19-2017, 10:09 PM
gmayor's Avatar
gmayor gmayor is offline Seeking rule/code to send emails which have been moved by rules to be autoforwarded Windows 10 Seeking rule/code to send emails which have been moved by rules to be autoforwarded Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

The particular error occurs because of the line
Code:
Sub MoveFolders()
before the variable declaration. Subs should go after the Private variable declarations.

I see you have given separate variable names to each folder, but you have changed the folder names. The foldernames should reflect exactly the names of the folders - complete with spaces. What I was suggesting was that you name the variables to match the folders e.g.

Code:
Set WSJEveningWrap = GetNS(olApp).GetDefaultFolder(olFolderInbox).Folders("Briefing").Folders("WSJ Evening Wrap").Items
etc, however the numbered variable names you have used should work provided the folder names are correct.

You will need a separate sub for each of those folder variables
Code:
Private Sub Newsletters9_ItemAdd(ByVal item As Object)
etc
There should be a space between Set and each variable name and there is no default folder WSJEveningWrap e.g.
Code:
SetNewsLetters9 = GetNS(olApp).GetDefaultFolder(WSJEveningWrap).Items
should be
Code:
Set NewsLetters9 = GetNS(olApp).GetDefaultFolder(olFolderInbox).Folders("Briefing").Folders("WSJ Evening Wrap").Items
or as I originally suggested
Code:
Set WSJEveningWrap = GetNS(olApp).GetDefaultFolder(olFolderInbox).Folders("Briefing").Folders("WSJ Evening Wrap").Items
Rather than create dozens of variables and subs for all those folders, Create the code for just one of your folders to test it, then add code for all the other folders to match the code that works.
__________________
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking rule/code to send emails which have been moved by rules to be autoforwarded Outlook rule to not send if attachment name doesn't match criteria SerenityNetworks Outlook 10 03-20-2016 10:56 AM
Seeking rule/code to send emails which have been moved by rules to be autoforwarded Want to set up a rule to move sent emails mylan Outlook 2 07-08-2014 05:10 AM
Rule to remove duplicate emails? ReviTULize Outlook 0 05-14-2013 01:15 PM
Rule doesn't work on BCC emails LeakyMemory Outlook 0 04-21-2012 04:07 AM
Rule=Delayed send markg2 Outlook 0 08-01-2010 07:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:32 AM.


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