(自动热键)需要帮助来选择不同的Excel单元格,"+1"的东西。或者我不知道怎么称呼它



我需要使用自动热键进行Excel自动化的帮助。。

所以我想选择";A1〃;单元格在第一个输入中,然后对于第二个、第三个和下一个输入,我想选择";A";cell+1,因此;A";在第二个INPUT中选择的单元格将为A2";A";在第三个INPUT中选择的单元格将是A3等…

所以很可能是这样的。。

INPUT1:
X=1
oExcel := ComObjActive("Excel.Application")
oExcel.Sheets("SHEET").Activate
oExcel.Range("A1").Select
goto, INPUTX:
INPUTX:
X = +1
oExcel := ComObjActive("Excel.Application")
oExcel.Sheets("SHEET").Activate
oExcel.Range("A(X)").Select

但我不知道如何用AHK代码正确地写它。。。。有人能帮我解决这个问题吗?非常感谢。。。

不用担心,你就快到了。我想这就是你想要的。您可能想要循环,并且还需要将数字连接到单元格名称中

DoMyStuff:
/* You only need to get the Excel COM object once. 
* So we do this here, outside of the loop. */
oExcel := ComObjActive("Excel.Application")
; activate the sheet once.
oExcel.Sheets("SHEET").Activate
Loop, 100 ; this repeats the following code from 1 to 100.
{
/* A_Index in a "Loop" block becomes 1..2..3.. 
* to 100 (each loop pass) or whatever is set above. 
* With AHK v1.1, you can concat like so: 
* "something" 42 "anotherthing"
* gives
* "something42anotherthing"
*/
oExcel.Range("A" A_Index).Select 
}
return

相关内容