Code Optimization: Call rejected errors

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jc0r
Posts: 29
Joined: 27 Nov 2015, 07:09

Code Optimization: Call rejected errors

08 Dec 2021, 06:47

Hi all,

Can anyone suggest a better way of running the below code maybe without the use of a loop as i intermittenly get "Call was rejected by callee" errors on row := used.Rows(A_Index) & If (row.Cells(12).Text != "TRUE"). I'm not editing anything in Excel although i do have a 3rd party program displaying its data on a sheet via COM. Ive tried inserting sleeps, even ridiculous long sleeps of 10000 and they still appear. When the code works as expected it only take around 3 seconds to execute the maximum number of send commands to Book.exe and the CalcMyArr macro only takes around 3 milliseconds to execute.

Code: Select all

#Persistent
XL := ComObjActive("Excel.application"), used := XL.Sheets(2).UsedRange

SetTimer, Check, 10000
Check:
XL.Run("CalcMyArr")
Sleep, 1000
Loop, % used.Rows.Count 
{
 row := used.Rows(A_Index)
 If (row.Cells(12).Text != "TRUE")
  Continue
 WinActivate, ahk_exe Book.exe
 WinWaitActive, ahk_exe Book.exe
 Send, % row.Cells(14).Text "`n" row.Cells(13).Text
}
Return
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Code Optimization: Call rejected errors

08 Dec 2021, 10:56

IMO, VBA indices are 0-based. So valid row indices would be 0 thru used.Rows.Count - 1 (i.e.A_Index - 1).
User avatar
flyingDman
Posts: 2821
Joined: 29 Sep 2013, 19:01

Re: Code Optimization: Call rejected errors

08 Dec 2021, 11:32

I cannot replicate the error. It works fine here. Although I would have used a For loop, a regular loop is fine. It's not an issue with index. used.Rows(1).cells(1).text shows me the content of the top left cell. used.Rows(0).cells(1).text gives me an error (as expected). Have you tried Excel_Get() ?. Search for it on the forum.
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], jdfnnl, serenite, yanjujino1 and 327 guests