ERROR 0X800A03EC ahk with excel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
brunopare
Posts: 11
Joined: 15 Jun 2021, 13:37

ERROR 0X800A03EC ahk with excel

Post by brunopare » 05 Jul 2021, 12:54

Hey guys, i'm here again, first i would to thanks for this forum, i finished my first ahk script. For now i'm working in a new scrip, and having some problems haha :D

On the first if everthing is ok the variable material receive the value of column M , but, on the Else if i have a error ( attached ) which points directly to the "material" line ( material := Excel.Range("M" controle_mat).Value ). I'm just using the ComObjCreate to work with excel. And how i said the first if works pretty well. Someone can help me ? I will attach the full code if will help.

Code: Select all

Excel := ComObjCreate("Excel.Application") 
Excel.Workbooks.Open("C:\Users\XXXXXX\Desktop\XXXXXX\XXXXXXXX.xlsx") 
Excel.Visible := True 
linhacontrole := 22
loop 1 {
	tipo_obra := Excel.Range("B" linhacontrole).value
	num_obra := Excel.Range("C" linhacontrole).Value
	;Abrindo Janela e acessando movimento 2-1-2
	WinActivate,XXXXXXXXXXXXXX - \\Remote
	Sleep, 2000
	MouseClick, left,  196, 43 ;propriedade para clicar em Movimentos, pode variar de a cordo com a resolução do usuário.
	Send, 2
	Send, 2
	Send, 1 
	Sleep, 2000
	Send, %num_obra%
	Sleep, 2000
	;Clica em incluir 
	MouseClick, left,  29,  91
	Sleep, 2000
	
	
	if (linhacontrole <=21 ){
		
		controle_mat := 3
		quantidade :=""
		loop 11{
			material := Excel.Range("M" controle_mat).Value
			Send, %material%{TAB}
			if (tipo_obra = "URBANO"){
				quantidade := Excel.Range("O" controle_mat).value
			}
			Else if (tipo_obra ="RURAL"){
				quantidade :=Excel.Range("P" controle_mat).value
			}
			Send, %quantidade%{TAB}
			Send, 0{TAB}
			Send, {TAB}{TAB}{TAB}
			controle_mat := controle_mat + 1 
		}
	}
		
	Else if (linhacontrole >=22) AND (linhacontrole <=31){
		controle_mat := 24
		quantidade := Excel.Range("O" controle_mat).Value
		loop 3 {
			material := Excel.Range("M" controle_mat).Value
			Send, %material%{TAB}
			Send, %quantidade%{TAB}
			Sleep, 3000
			Send, 0{TAB}
			Send, {TAB}{TAB}{TAB}
			controle_mat = controle_mat + 1
			}
		}
	Send, {F11}
	Sleep, 1000
linhacontrole := linhacontrole + 1 
}
 
Attachments
ERRO.png
ERRO.png (17.05 KiB) Viewed 245 times
CODIGO.png
CODIGO.png (33.49 KiB) Viewed 245 times

User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: ERROR 0X800A03EC ahk with excel

Post by boiler » 05 Jul 2021, 13:51

It's because this line isn't incrementing the variable since you used the legacy assignment operator = instead of the expression assignment operator :=:

Code: Select all

controle_mat = controle_mat + 1

The second time through the loop, the variable controle_mat contains the string controle_mat + 1 instead of the value 25, so change it to this:

Code: Select all

controle_mat := controle_mat + 1
or:

Code: Select all

controle_mat++

Post Reply

Return to “Ask for Help (v1)”