Code: Select all
"Error: 0x80010001 - Call was rejected by callee"
So try/catch for each and every Excel COM Interface was implemented in the code and it solved the problem allowing to reduce the delays to 10ms. Impressive!
Code: Select all
Sleep, 10
loop
{
try (X1.Range("A1").Value := "=ROW()", error:=0)
catch error
sleep 10
if (!error)
break
} ; INSERT ROW NUMBER FORMULA IN CELL A1
Sleep, 10
loop
{
try (X1.Range("A1").Copy, error:=0)
catch error
sleep 10
if (!error)
break
}
; COPY FORMULA IN FIRST CELL
Sleep, 10
loop
{
try (X1.Range("A2:A" . SHEETS_COUNT).Select, error:=0)
catch error
sleep 10
if (!error)
break
} ; SELECT REGION TO COPY TO
However, I don't want to write all that code for each Excel COM Interface call and would like to have a function in an external .ahk file with the try/catch functionality.
And here come the bad news. The external function file requires once again to have delays of 500-600ms or more or it will fail way too often.
Script code with function calls:
Code: Select all
X1 := ComObjCreate(("Excel.Application")) ; CONNECT TO THE EXCEL WORKBOOK
X1.Workbooks.Open("C:\Users\aircooled\Private\My_Book.xlsx")
Sleep, 500
X1.Visible:=True ; OPENS THE EXCEL WORKBOOK
Sleep, 500
Loop, 4
{
Sleep, 500
TTL := getFreeMem(X1.Sheets("Sheet2").Range("C" . A_Index).Select)
Sleep, 500
TTL := UpdateCell(X1.Sheets("Sheet2").Range("C" . A_Index).Value := A_Index)
}
#Include C:\Users\aircooled\Private\\My_Function2.ahk
Code: Select all
getFreeMem(ByRef THISLINK)
{
sleep 200
loop
{
try (A_VAR := THISLINK)
catch error
sleep 500
if (!error)
break
}
return 0
}
UpdateCell(ByRef THISLINK)
{
sleep 200
loop
{
try (THISLINK, error:=0)
catch error
sleep 500
if (!error)
break
}
return 0
}
Code: Select all
"Error: 0x80010001 - Call was rejected by callee"