This is the code I found on the board here:
Code: Select all
; This script gets a range of cells in column A and B. (Like selecting cell A2 and then pressing Ctrl+Shift+Down and
; then Shift+Right.) Then each time the Ctrl+F12 hotkey is pressed it sends the next value.
; Usage:
; Press Ctrl+F12 to send the next value.
; Constants
xlDown := -4121
WorkbookPath := A_ScriptDir "\MyWorkbook.xlsx" ; <-- Change this to the path of your workbook
xlApp := ComObjCreate("Excel.Application") ; Create an instance of Excel
xlApp.Visible := true ; Make Excel visible
MyWorkbook := xlApp.Workbooks.Open(WorkbookPath) ; Open the workbook
CellA2 := xlApp.Cells(2, 1) ; Store a reference to cell A2
LastCell := CellA2.End(xlDown).Offset(0, 1) ; Store the last cell. .End is like pressing Ctrl+Down
MyRange := xlApp.Range(CellA2, LastCell) ; Store a reference to the Range A2:LastCell
CellNumber := 1 ; This variable will store the cell number to use
CellCount := MyRange.Cells.Count ; Store the count of cells in the range
return
^F12:: ; Ctrl+F12 hotkey
SendRaw % MyRange.Cells(CellNumber).Text ; Send the current cell specified by 'CellNumber'
CellNumber++ ; Increase 'CellNumber' by one
if (CellNumber > CellCount) { ; If 'CellNumber' is greater than the total amount of cells...
MsgBox, 64, Info, Finished. No more cells. ; Done
CellNumber := 1
}
return
; References
; https://autohotkey.com/boards/viewtopic.php?p=112648#p112648
; https://github.com/ahkon/MS-Office-COM-Basics/blob/master/Examples/Excel/Cells_in_a_column.ahk
Code: Select all
+!a::
FormatTime, CurrentDate, , MM/dd/yy
InputBox, CID, CID, CID Number, , 200, 200
InputBox, Order, Order, Order Number, , 200, 200
if ErrorLevel
MsgBox, CANCEL was pressed.
; Create IE instance
Run http://projects/PWA/ERP Project/Team Portal/Lists/New Triage/NewForm.aspx
Sleep,500
WinWait, ERP Triage - New Item,
IfWinNotActive, ERP Triage - New Item, , WinActivate, ERP Triage - New Item,
WinWaitActive, ERP Triage - New Item,
Sleep, 2000
Send {t}{t}{t}
Send, {Tab}
Sleep, 100
Send {k}
Sleep, 100
Send, {Tab 4}
Sleep, 100
Send rwebber
Sleep, 100
Send, {Tab 3}
Sleep, 100
Send {4}
Sleep, 100
Send, {Tab}
Sleep, 100
Send {e}{e}{e}{e}{e}{e}{e}
Sleep, 100
Send, {Tab 1}
Sleep, 100
Send {k}
Sleep, 100
Send, {Tab 1}
Sleep, 100
Send {o}{o}
Sleep, 100
Send, {Tab 1}
Sleep, 100
Send {o}{o}
Sleep, 100
Send, {Tab 1}
Sleep, 100
Send {a}{a}{a}{a}{a}
Sleep, 100
Send, {Tab 16}
Sleep, 100
Send %CID%
Sleep, 100
Send, {Tab 2}
SendInput %CurrentDate%
Send, {Tab 3}
Sleep, 100
Send, 0
Send, {Tab}
Send %Order%
Sleep, 100
Send, {Tab 1}
Sleep, 100
Send Suspended order, please fix
Return
Sheet name = "Sheet1" (there are a lot of sheets in this workbook)
C2 = Customer #
F2 = Order #
After the 1st ticket is create (after my script sends "Suspended order, please fix") I would like for it to make the next ticket using the Customer # from cell C3 & order # from cell F3, then C4 & F4 and so on till the end of the list. Any help would be greatly apricated. Thank you in advance!