How do I run a rule by using a toolbar icon?

Status
Not open for further replies.
D

DLGolfs

I have Outlook 2007 and have a rule set up to delte spam by detecting certain

words in the spam.

Here is what someone gave me but it does not work:

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

If I run it it highlights the set oRule line and stops, I guess. I know

nothing about programming, I'll admit, but am not ignorant on computer

processes. I thought if I could make a macro to run a rule then I could put

the macro in a toolbar icon and just click on it instead of having to go

through a series of clicks.

What do you think? Is the formula wrong or what?
 
What does the error message say? I guess the rule "Delete Spam" doesn't

exist.

Best regards

Michael Bauer

Am Thu, 18 Mar 2010 17:48:01 -0700 schrieb DLGolfs:


> I have Outlook 2007 and have a rule set up to delte spam by detecting


certain
> words in the spam.
> Here is what someone gave me but it does not work:

> 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
> If I run it it highlights the set oRule line and stops, I guess. I know
> nothing about programming, I'll admit, but am not ignorant on computer
> processes. I thought if I could make a macro to run a rule then I could


put
> the macro in a toolbar icon and just click on it instead of having to go
> through a series of clicks.
> What do you think? Is the formula wrong or what?
 
No error just highlights the the line

Yes, the rul Delete Spam does exisit, I can run it manually all the time.

I tried to export the rules and put the file here but it did not work.

I have the rule name Delete Spam

"Michael Bauer " wrote:



> What does the error message say? I guess the rule "Delete Spam" doesn't
> exist.

> > Best regards
> Michael Bauer
>

>

> Am Thu, 18 Mar 2010 17:48:01 -0700 schrieb DLGolfs:
>
> > I have Outlook 2007 and have a rule set up to delte spam by detecting

> certain
> > words in the spam.
> > Here is what someone gave me but it does not work:
> > 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
> > If I run it it highlights the set oRule line and stops, I guess. I know
> > nothing about programming, I'll admit, but am not ignorant on computer
> > processes. I thought if I could make a macro to run a rule then I could

> put
> > the macro in a toolbar icon and just click on it instead of having to go
> > through a series of clicks.
> > What do you think? Is the formula wrong or what?

> .
>
 
No error just highlights the line as I stated below. That is it.

Yes, the rule Delete Spam does exisit, I can run it manually all the time.

I tried to export the rules and put the file here but it did not work.

I have the rule name Delete Spam

"Michael Bauer " wrote:



> What does the error message say? I guess the rule "Delete Spam" doesn't
> exist.

> > Best regards
> Michael Bauer
>

>

> Am Thu, 18 Mar 2010 17:48:01 -0700 schrieb DLGolfs:
>
> > I have Outlook 2007 and have a rule set up to delte spam by detecting

> certain
> > words in the spam.
> > Here is what someone gave me but it does not work:
> > 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
> > If I run it it highlights the set oRule line and stops, I guess. I know
> > nothing about programming, I'll admit, but am not ignorant on computer
> > processes. I thought if I could make a macro to run a rule then I could

> put
> > the macro in a toolbar icon and just click on it instead of having to go
> > through a series of clicks.
> > What do you think? Is the formula wrong or what?

> .
>
 
if you modify the code to this:

On Error Resume Next

Set oRule = colRules.Item("Delete Spam")

MsgBox Err.Description

what does the prompt tell you?

Best regards

Michael Bauer

Am Sat, 20 Mar 2010 03:23:01 -0700 schrieb DLGolfs:


> No error just highlights the line as I stated below. That is it.
> Yes, the rule Delete Spam does exisit, I can run it manually all the time.

> I tried to export the rules and put the file here but it did not work.
> I have the rule name Delete Spam

> "Michael Bauer " wrote:
>
>

>
>> What does the error message say? I guess the rule "Delete Spam" doesn't
> > exist.
>

>> > > Best regards
> > Michael Bauer
> >

> >

>
>
>> Am Thu, 18 Mar 2010 17:48:01 -0700 schrieb DLGolfs:
> >
> >> I have Outlook 2007 and have a rule set up to delte spam by detecting

> > certain
> >> words in the spam.
> >> Here is what someone gave me but it does not work:
> >
>>> 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
> >> If I run it it highlights the set oRule line and stops, I guess. I know
> >> nothing about programming, I'll admit, but am not ignorant on computer
> >> processes. I thought if I could make a macro to run a rule then I could

> > put
> >> the macro in a toolbar icon and just click on it instead of having to


go
> >> through a series of clicks.
> >> What do you think? Is the formula wrong or what?

> > .
> >
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1
G Save attachment run a script rule Outlook VBA and Custom Forms 0
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
O Outlook 2016 This rule will only run when you check your email in Outlook.... Using Outlook 4
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
Bri the Tech Guy Run Script rule not running for newly arriving messages Outlook VBA and Custom Forms 25
Vijay Error in rule- Run a script Using Outlook 1
Diane Poremsky Run a Script Rule: Send a New Message when a Message Arrives Using Outlook 2
L Run a Script Rule doesn't work Using Outlook 5
L Cannot run script from rule Outlook VBA and Custom Forms 7
O modify vba to run it as script rule Outlook VBA and Custom Forms 8
Gary Brown Outlook 2013 VBA to run a rule Outlook VBA and Custom Forms 13
Jeff Rott Diane Question on "Use in a Run a Script Rule" Outlook VBA and Custom Forms 1
J outlook rule doesn't run automatically Using Outlook 0
O Run Rule to Rename Email and Add to Tasks Using Outlook 4
D Create a macro in Outlook to run a rule Outlook VBA and Custom Forms 32
L Run script rule not exectued for first few mails Outlook VBA and Custom Forms 2
J Outlook, Word, Access crash unless run in Admin mode - time dependent it seems Using Outlook 10
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
V Outlook macros no longer run until VB editor is opened Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
N Outlook 2021 'Run Script" Rules? Outlook VBA and Custom Forms 4
T Outlook 2010 Errore run-time -2147417851 (80010105) Metodo delete ContactItem non riuscito Outlook VBA and Custom Forms 0
U Outlook 2019 VBA run-time error 424 Outlook VBA and Custom Forms 2
D Outlook 2013 Macros only run in VB editor, not in drop down or button Outlook VBA and Custom Forms 14
D We're sorry but outlook has run into an error Using Outlook 6
M White square in body of Outlook Messages (O2016 Version 2012 32bit Click To Run) Using Outlook 4
C Auto Run VBA Code on new email Outlook VBA and Custom Forms 1
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
Y Outlook 2013 Run A Script Outlook VBA and Custom Forms 4
B run scripts Using Outlook 1
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
O Run macro automatically at sending an email Using Outlook 11
P errors appear every time I run SCANPST Using Outlook 3
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
B Wanting to run a script that will filter any body that has a russian link in it. Outlook VBA and Custom Forms 5
P Run Time Error 91 when linking contact to task in VBA Outlook VBA and Custom Forms 1
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
Bri the Tech Guy Registry Tweak to make "Run a Script" Action Available Outlook VBA and Custom Forms 2
J Custom form code doesn't run Outlook VBA and Custom Forms 2
J VBA Run When Reply Outlook VBA and Custom Forms 4
Vijay Run script doesn't work in outlook Using Outlook 1
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1

Similar threads

Back
Top