Outlook COM failure

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
JoeWinograd
Posts: 2213
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Outlook COM failure

03 Mar 2024, 10:45

Hi Folks,

I'm working on an interesting thread with @ShatterCoder:
viewtopic.php?f=76&t=126600

It has resulted in a tangential issue that I think is better in a new question.

ShatterCoder's post has this line of code, which works fine:

Code: Select all

   msg .= Rules.Item(OuterDex := A_index).Name "`n"
Seems to me that it simply has the assignment statement as a parameter in the Outlook COM call. I think that the line of code above should be equivalent to these two lines of code (i.e., putting the assignment statement into a prior line of code):

Code: Select all

   OuterDex := A_index
   msg .= Rules.Item(OuterDex).Name "`n"
But those two lines of code fail with this error dialog:

ahk outlook com failure.png
ahk outlook com failure.png (28.83 KiB) Viewed 138 times

Anyone know why? Thanks much, Joe
User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: Outlook COM failure

06 Mar 2024, 00:27

Hi Joe, could be that the index of the object is of a variant type, so the object method might be taking the string value of the variable name OuterDex by default when the type cannot be ascertained. Yet in the next line A_Index is used, so no problem with the type in that case.
A For - each Item in Rules approach is more reliable if it can be implemented here.
HTH
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
User avatar
JoeWinograd
Posts: 2213
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Outlook COM failure

06 Mar 2024, 00:50

lmstearn wrote:might be taking the string value of the variable name
Hi lmstearn,
Great call! That's surely what's happening, because these two lines do work:

Code: Select all

   OuterDex := A_index
   msg .= Rules.Item(OuterDex+0).Name "`n"
Thanks very much! Regards, Joe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 145 guests