View Single Post
  #9  
Old March 5th 10, 09:54 PM posted to microsoft.public.outlook.program_vba
DLGolfs
external usenet poster
 
Posts: 25
Default Create a macro in Outlook to run a rule

There is no code module only class module and module, so I used module.

cut and pasted, then ran and got run time error 438, Object does not support
property or method,
then it higlights this line:
Set colRules = oStore.Rules

"Ken Slovak - [MVP - Outlook]" wrote:

The macro should be in a code module.

So what happens? Do you get any errors or what? It might be necessary to
expand that one-liner so you can see where things are failing. Let's try
that:

Sub RunRuleDeleteSpam()
Dim oNS As Outlook.NameSpace
Dim oStore As Outlook.Store
Dim colRules As Outlook.Rules
Dim oRule as Outlook.Rule

Set oNS = Application.GetNameSpace("MAPI")
Set oStore = oNS.DefaultStore
Set colRules = oStore.Rules
Set oRule = colRules.Item("Delete Spam")
oRule.Execute
End Sub

Put your cursor in that macro in the VBA project and press F5. See what
happens when the macro executes, if you get any errors or what.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"DLGolfs" wrote in message
...
ok, copy , pasted below into the editor module, run "macro" from VBA and
outlook and nothing happens, sorry

I put in in a module and a design module and neither work.


.

Ads