outlook 2007 - unable to modify rule condition via program

G

Gilles Pion

Hello everybody,

I'm unable to make the following code works, the line
"oRule.Conditions.OnLocalMachine.Enabled = False" always produce this message:

"execution error '-9707964987 (c6204005)':
invalid operation. Unable to activate this rule action because the rule is
readonly, is invalid for this rule kind or conflicts with another rule action""

(please take into account that since I'm using french version of Outlook this is
a translation, the equivalent english error text may be slightly different )


And, here's my code:

Sub FixRules()
Dim oRules As Outlook.Rules
Dim oRule As Outlook.Rule

Set oRules = Application.Session.DefaultStore.GetRules()

For Each oRule In oRules
If oRule.Conditions.OnLocalMachine.Enabled Then
'MsgBox ("processing " & oRule.name)
oRule.Conditions.OnLocalMachine.Enabled = False
End If
Next oRule
End Sub

Thanks for any help,
 
M

Michael Bauer [MVP - Outlook]

See the object browser (f2): The OnLocalMachine property is read-only.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Sun, 28 Dec 2008 12:16:57 +0100 schrieb Gilles Pion:
 
G

Gilles Pion

Ref: said:
See the object browser (f2): The OnLocalMachine property is read-only.

That's very strange: since it is possible to modify this property using Outlook
user interface, I thought that it would automatically imply it to be read/write.
This is somewhat disappointing.

And, following your advice, I've checked the object browser. Even more
strangely, others RuleConditions members (for example the "Importance" property)
are also documented as readonly but the "enabled" value *can* be changed. Have a
look at those lines from VBA execution window:

oRule.Conditions.Importance.Enabled = True
? oRule.Conditions.Importance.Enabled
Vrai ' // my outlook speaks french...
oRule.Conditions.Importance.Enabled = False
? oRule.Conditions.Importance.Enabled
Faux

but
oRule.Conditions.OnLocalMachine.Enabled = False
still produce the error

Any clues to find a method to change that value using VBA code?
 
K

Ken Slovak - [MVP - Outlook]

The value of RuleCondition.Enabled for OnLocalMachine may always be set to
True no matter what code you use if other conditions in the rule mandate
that setting. The example in the Help for the Object Browser mentions the
condition olConditionAccount as one of those settings. Is it possible that
your rule also sets the state of another condition that's forcing
OnLocalMachine.Enabled to True?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top