A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro to Run Rules



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 28th 09, 10:00 PM posted to microsoft.public.outlook.program_vba
Kash
external usenet poster
 
Posts: 4
Default Macro to Run Rules

How can I run only specific rules in 2007?
Ads
  #2  
Old June 28th 09, 11:28 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Macro to Run Rules

The code sample at http://www.outlookcode.com/codedetail.aspx?id=1266 shows
how to run all rules against the Inbox. If you want to run only certain
rules, return each rule using myRules.Item("name of rule") and then call its
Execute method.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Kash" wrote in message
...
How can I run only specific rules in 2007?



  #3  
Old June 29th 09, 08:08 AM posted to microsoft.public.outlook.program_vba
Kash
external usenet poster
 
Posts: 4
Default Macro to Run Rules

I'm able to run only one macro.. 'Clear categories'
  #4  
Old June 29th 09, 01:58 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Macro to Run Rules

Code?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Kash" wrote in message
...
I'm able to run only one macro.. 'Clear categories'



  #5  
Old June 29th 09, 08:19 PM posted to microsoft.public.outlook.program_vba
Kash
external usenet poster
 
Posts: 4
Default Macro to Run Rules

Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim count As Integer
Dim ruleList As String
'On Error Resume Next

' get default store (where rules live)
Set st = Application.Session.DefaultStore
' get rules
Set myRules = st.GetRules

' iterate all the rules
For Each rl In myRules
' determine if it's an Inbox rule
If rl.RuleType = olRuleReceive Then
' if so, run it
rl.Execute ShowProgress:=True
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
Next

' tell the user what you did
ruleList = "These rules were executed against the Inbox: " & vbCrLf &
ruleList
MsgBox ruleList, vbInformation, "Macro: RunAllInboxRules"

Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub


  #6  
Old June 30th 09, 06:07 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Macro to Run Rules

If you step through the code in the debugger, what happens inside the For
Each loop?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Kash" wrote in message
...
Sub RunAllInboxRules()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim count As Integer
Dim ruleList As String
'On Error Resume Next

' get default store (where rules live)
Set st = Application.Session.DefaultStore
' get rules
Set myRules = st.GetRules

' iterate all the rules
For Each rl In myRules
' determine if it's an Inbox rule
If rl.RuleType = olRuleReceive Then
' if so, run it
rl.Execute ShowProgress:=True
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
Next

' tell the user what you did
ruleList = "These rules were executed against the Inbox: " & vbCrLf &
ruleList
MsgBox ruleList, vbInformation, "Macro: RunAllInboxRules"

Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub

"Kash" wrote in message
...
I'm able to run only one macro.. 'Clear categories'



"Sue Mosher [MVP]" wrote in message
...
The code sample at http://www.outlookcode.com/codedetail.aspx?id=1266
shows
how to run all rules against the Inbox. If you want to run only certain
rules, return each rule using myRules.Item("name of rule") and then call
its
Execute method.

"Kash" wrote in message
...
How can I run only specific rules in 2007?





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Run Rules ausfilminstitute Outlook and VBA 3 March 17th 10 12:26 PM
Macro to Write Rules Stratuser Outlook and VBA 4 June 23rd 09 10:40 PM
rules to run macro DSPettit Outlook - General Queries 3 April 27th 07 04:06 PM
Macro to run Rules in batch bman342 Outlook and VBA 4 March 14th 07 06:16 PM
Rules an macro Gerd Neumann Outlook and VBA 4 May 17th 06 09:48 PM


All times are GMT +1. The time now is 07:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.