Group:  Microsoft Outlook ยป microsoft.public.outlook.program_vba
Thread: outlook 2007 - unable to modify rule condition via program

Geek News

outlook 2007 - unable to modify rule condition via program
Gilles Pion <nosuchuser[ at ]nosuchdomain.com> 12/28/2008 11:16:57 AM
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,

Re: outlook 2007 - unable to modify rule condition via program
"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> 12/29/2008 9:40:22 AM


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:

[Quoted Text]
> 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,
Re: outlook 2007 - unable to modify rule condition via program
Gilles Pion <nosuchuser[ at ]nosuchdomain.com> 12/30/2008 10:26:29 PM
Ref: <18i6j8glz43ux.ibdha7p66n8u.dlg[ at ]40tude.net> de "Michael Bauer [MVP -
Outlook]" <mb[ at ]mvps.org>
[Quoted Text]
>
>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?
Re: outlook 2007 - unable to modify rule condition via program
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 12/31/2008 2:28:49 PM
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?

--
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


"Gilles Pion" <nosuchuser[ at ]nosuchdomain.com> wrote in message
news:g66ll417qparvkotug8ouhp1iepgogoa26[ at ]4ax.com...
[Quoted Text]
> Ref: <18i6j8glz43ux.ibdha7p66n8u.dlg[ at ]40tude.net> de "Michael Bauer [MVP -
> Outlook]" <mb[ at ]mvps.org>
>>
>>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?

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net