![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
![]() Each folder needs its own unique variable name. You can only apply the variable 'Newsletters' to one of the folders - 'Newsletters' was the example used in the quoted link - more meaningful unique variable names would be required (e.g. the folder names with the spaces replaced by underscore characters). Note that there were two folders in the quoted link, each with its own variable name and associated macro. You have more than 50 folders here? If you set the same variable name to multiple folders, only the last folder to be set i.e. folder "NSAR" is the folder associated with that variable name. You need to create an event for each of the 50+ folders. Take another look at the link you quoted.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#2
|
|||
|
|||
![]()
Graham, thanks for persisting. I've interpreted what you have advised in the following code, placed in "ThisOutlookSession", but it's returning a compile error message "Invalid Attribute in Sub or Function" at the line indicated below. Grateful for any further assistance.
Code:
Option Explicit Sub MoveFolders() Private WithEvents NewsLetters9 As outlook.Items <<<<<<<DEBUGGER FINDS COMPILE ERROR HERE Private WithEvents NewsLetters10 As outlook.Items Private WithEvents NewsLetters11 As outlook.Items Private WithEvents NewsLetters12 As outlook.Items Private WithEvents NewsLetters13 As outlook.Items Private WithEvents NewsLetters14 As outlook.Items Private WithEvents NewsLetters15 As outlook.Items Private WithEvents NewsLetters16 As outlook.Items Private WithEvents NewsLetters17 As outlook.Items Private WithEvents NewsLetters18 As outlook.Items Private WithEvents NewsLetters19 As outlook.Items Private WithEvents NewsLetters20 As outlook.Items Private WithEvents NewsLetters21 As outlook.Items Private WithEvents NewsLetters22 As outlook.Items Private WithEvents NewsLetters23 As outlook.Items Private WithEvents NewsLetters24 As outlook.Items Private WithEvents NewsLetters25 As outlook.Items Private WithEvents NewsLetters26 As outlook.Items Private WithEvents NewsLetters27 As outlook.Items Private WithEvents NewsLetters28 As outlook.Items Private WithEvents NewsLetters29 As outlook.Items Private WithEvents NewsLetters30 As outlook.Items Private WithEvents NewsLetters31 As outlook.Items Private WithEvents NewsLetters32 As outlook.Items Private WithEvents NewsLetters33 As outlook.Items Private WithEvents NewsLetters34 As outlook.Items Private WithEvents NewsLetters35 As outlook.Items Private WithEvents NewsLetters36 As outlook.Items Private WithEvents NewsLetters37 As outlook.Items Private WithEvents NewsLetters38 As outlook.Items Private WithEvents NewsLetters39 As outlook.Items Private WithEvents NewsLetters40 As outlook.Items Private WithEvents NewsLetters42 As outlook.Items Private WithEvents NewsLetters43 As outlook.Items Private WithEvents NewsLetters44 As outlook.Items Private WithEvents NewsLetters45 As outlook.Items Private WithEvents NewsLetters46 As outlook.Items Private WithEvents NewsLetters47 As outlook.Items Private WithEvents NewsLetters48 As outlook.Items Private WithEvents NewsLetters49 As outlook.Items Private WithEvents NewsLetters50 As outlook.Items Private WithEvents NewsLetters51 As outlook.Items Private WithEvents NewsLetters52 As outlook.Items Private WithEvents NewsLetters53 As outlook.Items Private WithEvents NewsLetters54 As outlook.Items Private WithEvents NewsLetters55 As outlook.Items Private WithEvents NewsLetters56 As outlook.Items Private WithEvents NewsLetters57 As outlook.Items Private WithEvents NewsLetters58 As outlook.Items Private WithEvents NewsLetters59 As outlook.Items Private WithEvents NewsLetters60 As outlook.Items Private WithEvents NewsLetters61 As outlook.Items Private WithEvents NewsLetters62 As outlook.Items Private WithEvents NewsLetters63 As outlook.Items Private WithEvents NewsLetters64 As outlook.Items Private WithEvents NewsLetters65 As outlook.Items Private WithEvents NewsLetters66 As outlook.Items Private WithEvents NewsLetters67 As outlook.Items Private WithEvents NewsLetters68 As outlook.Items Private WithEvents NewsLetters69 As outlook.Items Private WithEvents NewsLetters70 As outlook.Items Private WithEvents NewsLetters71 As outlook.Items Private WithEvents NewsLetters72 As outlook.Items Private WithEvents NewsLetters73 As outlook.Items Private WithEvents NewsLetters74 As outlook.Items Private WithEvents NewsLetters75 As outlook.Items Private olItem As outlook.MailItem Private Sub Application_Startup() Dim olApp As outlook.Application Set olApp = outlook.Application SetNewsLetters9 = GetNS(olApp).GetDefaultFolder(WSJEveningWrap).Items SetNewsLetters10 = GetNS(olApp).GetDefaultFolder(WSJTechnologyUpdate).Items SetNewsLetters11 = GetNS(olApp).GetDefaultFolder(WSJRealTimeEconomics).Items SetNewsLetters12 = GetNS(olApp).GetDefaultFolder(WSJOpinion).Items SetNewsLetters13 = GetNS(olApp).GetDefaultFolder(WSJLifeAndArts).Items SetNewsLetters14 = GetNS(olApp).GetDefaultFolder(myFT).Items SetNewsLetters15 = GetNS(olApp).GetDefaultFolder(WSJ10point).Items SetNewsLetters16 = GetNS(olApp).GetDefaultFolder(FTUKPolitics).Items SetNewsLetters17 = GetNS(olApp).GetDefaultFolder(FTFreeLunch).Items SetNewsLetters18 = GetNS(olApp).GetDefaultFolder(FTBrussels).Items SetNewsLetters19 = GetNS(olApp).GetDefaultFolder(FTBrexit).Items SetNewsLetters20 = GetNS(olApp).GetDefaultFolder(FirstFT).Items SetNewsLetters21 = GetNS(olApp).GetDefaultFolder(LexEurope).Items SetNewsLetters22 = GetNS(olApp).GetDefaultFolder(CNBreakingNews).Items SetNewsLetters23 = GetNS(olApp).GetDefaultFolder(CNDailyNews).Items SetNewsLetters24 = GetNS(olApp).GetDefaultFolder(CNBriefing).Items SetNewsLetters25 = GetNS(olApp).GetDefaultFolder(FTEnergy).Items SetNewsLetters26 = GetNS(olApp).GetDefaultFolder(FTEditorsChoice).Items SetNewsLetters27 = GetNS(olApp).GetDefaultFolder(WSJEnergy).Items SetNewsLetters28 = GetNS(olApp).GetDefaultFolder(WSJCMOToday).Items SetNewsLetters29 = GetNS(olApp).GetDefaultFolder(Lex).Items SetNewsLetters30 = GetNS(olApp).GetDefaultFolder(techFT).Items SetNewsLetters31 = GetNS(olApp).GetDefaultFolder(FTWhiteHouse).Items SetNewsLetters32 = GetNS(olApp).GetDefaultFolder(WSJTodaysPaperEurope).Items SetNewsLetters33 = GetNS(olApp).GetDefaultFolder(WSJTechnologyAlert).Items SetNewsLetters34 = GetNS(olApp).GetDefaultFolder(WSJPoliticsAlert).Items SetNewsLetters35 = GetNS(olApp).GetDefaultFolder(WSJNewsAlert).Items SetNewsLetters36 = GetNS(olApp).GetDefaultFolder(WSJEuropeAlert).Items SetNewsLetters37 = GetNS(olApp).GetDefaultFolder(WSJBrexit).Items SetNewsLetters38 = GetNS(olApp).GetDefaultFolder(WSJCity).Items SetNewsLetters39 = GetNS(olApp).GetDefaultFolder(IfG).Items SetNewsLetters40 = GetNS(olApp).GetDefaultFolder(Upshot).Items SetNewsLetters42 = GetNS(olApp).GetDefaultFolder(WSJCIOJournal).Items SetNewsLetters43 = GetNS(olApp).GetDefaultFolder(WSJPersonalTechnology).Items SetNewsLetters44 = GetNS(olApp).GetDefaultFolder(InfrastructureIntelligence).Items SetNewsLetters45 = GetNS(olApp).GetDefaultFolder(FTWeekend).Items SetNewsLetters46 = GetNS(olApp).GetDefaultFolder(FTNewsmine).Items SetNewsLetters47 = GetNS(olApp).GetDefaultFolder(CICBrexit).Items SetNewsLetters48 = GetNS(olApp).GetDefaultFolder(FTother).Items SetNewsLetters49 = GetNS(olApp).GetDefaultFolder(CommunicationsDirector).Items SetNewsLetters50 = GetNS(olApp).GetDefaultFolder(WSJBestofWeb).Items SetNewsLetters51 = GetNS(olApp).GetDefaultFolder(Economist).Items SetNewsLetters52 = GetNS(olApp).GetDefaultFolder(HBR).Items SetNewsLetters53 = GetNS(olApp).GetDefaultFolder(MRC).Items SetNewsLetters54 = GetNS(olApp).GetDefaultFolder(NAO).Items SetNewsLetters55 = GetNS(olApp).GetDefaultFolder(ONS).Items SetNewsLetters56 = GetNS(olApp).GetDefaultFolder(UKParliament).Items SetNewsLetters57 = GetNS(olApp).GetDefaultFolder(OpenUniversity).Items SetNewsLetters58 = GetNS(olApp).GetDefaultFolder(UKDefenceJournal).Items SetNewsLetters59 = GetNS(olApp).GetDefaultFolder(ESRC).Items SetNewsLetters60 = GetNS(olApp).GetDefaultFolder(NDA).Items SetNewsLetters61 = GetNS(olApp).GetDefaultFolder(BEIS).Items SetNewsLetters62 = GetNS(olApp).GetDefaultFolder(Wonkhe).Items SetNewsLetters63 = GetNS(olApp).GetDefaultFolder(MITSloan).Items SetNewsLetters64 = GetNS(olApp).GetDefaultFolder(Building).Items SetNewsLetters65 = GetNS(olApp).GetDefaultFolder(DepartmentofHealth).Items SetNewsLetters66 = GetNS(olApp).GetDefaultFolder(Raconteur).Items SetNewsLetters67 = GetNS(olApp).GetDefaultFolder(CIC).Items SetNewsLetters68 = GetNS(olApp).GetDefaultFolder(NYT).Items SetNewsLetters69 = GetNS(olApp).GetDefaultFolder(PoliticsHome).Items SetNewsLetters70 = GetNS(olApp).GetDefaultFolder(CNother).Items SetNewsLetters71 = GetNS(olApp).GetDefaultFolder(UniversitiesUK).Items SetNewsLetters72 = GetNS(olApp).GetDefaultFolder(InnovateUK).Items SetNewsLetters73 = GetNS(olApp).GetDefaultFolder(DesignCouncil).Items SetNewsLetters74 = GetNS(olApp).GetDefaultFolder(UKinaChangingEurope).Items SetNewsLetters75 = GetNS(olApp).GetDefaultFolder(NSAR).Items lbl_Exit: Exit Sub End Sub Private Sub Newsletters_ItemAdd(ByVal item As Object) On Error GoTo err_Handler Set olItem = item.Forward With olItem .To = "external.affairs@apm.org.uk" .Send End With lbl_Exit: Exit Sub err_Handler: MsgBox Err.Number & " - " & Err.Description GoTo lbl_Exit End Sub Function GetNS(ByRef app As outlook.Application) As outlook.NameSpace Set GetNS = app.GetNamespace("MAPI") lbl_Exit: Exit Function End Function Last edited by Hoxton118; 02-19-2017 at 10:32 AM. Reason: forgot code brackets |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
SerenityNetworks | Outlook | 10 | 03-20-2016 10:56 AM |
![]() |
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 |