Jump to content


Can someone review my Script... Loop doesn't seem to be work


  • Please log in to reply
5 replies to this topic

#1 StrykerMC

StrykerMC
  • Guests

Posted 19 July 2012 - 01:13 PM

I wrote this to assist our accounting department with invoice entry from a controlled excel file. I have everything working pretty well until it gets to the loop for multiple receivers. I have tried using "Loop Lines - 1 {" and "Loop %Lines% - 1" but neither works. If you notice the large amount of sleep time, we have a very old system and it needs the time delay.

Can someone take a look?

^1::
InputBox, Vendor, Vendor Number, , , 300, 150, 349, 184
InputBox, Date, Invoice Date, , , 300, 150, 349, 184
InputBox, Accounting, Account Number, No Periods or Spaces, , 300, 150, 349, 184
InputBox, Invoice, How Many Invoices?, , , 300, 150, 349, 184
InputBox, Lines, Number of Lines, How Many Lines is the Invoice?, , 300, 150, 349, 184
Sleep 100
CLICK 351,235
SEND %Vendor%
SLEEP 150
SEND {Tab}
SLEEP 150
SEND {Tab}
SLEEP 150
SEND {Tab}
SLEEP 150
SEND %Date%
SLEEP 150
SEND {Shift}+{Tab}
SLEEP 150
SEND {Shift}+{Tab}
SLEEP 150
SEND !{Tab}
SLEEP 5000
SEND ^c
Sleep 150
SEND !{Tab}
SLEEP 150
SEND {Alt}
SLEEP 150
SEND {Right}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Enter}
SLEEP 150
SEND {F8}
SLEEP 1500
SEND {F8}
SLEEP 100
SEND !{Tab}
Sleep 500
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 125
SEND {Left}
SLEEP 5000
SEND ^c
Sleep 150
SEND !{Tab}
SLEEP 150
SEND {Alt}
SLEEP 150
SEND {Right}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Enter}
SLEEP 150
SEND {Shift}+{F3}
SLEEP 500
SEND X
SLEEP 150
SEND {F5}
SLEEP 500
SEND {F8}
SLEEP 150

LOOP, Lines - 1
{
SEND {Ctrl}
SLEEP 150
SEND !{Tab}
Sleep 500
SEND {Down}
SEND {Alt}
SLEEP 5000
SEND ^c
Sleep 150
SEND !{Tab}
SEND {Alt}
SLEEP 150
SEND {Right}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Down}
SLEEP 150
SEND {Enter}
SLEEP 150
SEND {Shift}+{F3}
SLEEP 150
SEND X
SLEEP 150
SEND {F5}
SLEEP 150
SEND {F8}
SLEEP 150
}



#2 Guests

  • Guests

Posted 19 July 2012 - 01:15 PM

LOOP, % Lines - 1

; or

LoopTimes:=Lines-1

Loop %LoopTimes%


#3 StrykerMC

StrykerMC
  • Guests

Posted 19 July 2012 - 02:00 PM

Thank You!

Would you know why the ^c inside the loop isn't working?

#4 Guests

  • Guests

Posted 19 July 2012 - 02:08 PM

You could try Send {ctrl down}c{ctrl up}
You can simplify / shorten your code quite a bit like so
SetKeyDelay, 150
; ... you can now remove all / most sleep 150
Send {Down 5}{Enter}{F8}


#5 StrykerMC

StrykerMC
  • Guests

Posted 19 July 2012 - 03:24 PM

Awesome! That works beautifully. This may be the last thing.

Because the amount of invoice lines change through the excel document, I want it to set up a formula in excel to get the number of line and copy that number (My macro already does that), but now I need to find a way to input that data into the macro itself. I tried using an input box, and using Ctrl+P and Enter, but it does not do it. I also tried having the mouse click in the active cell, but that didn't work either. How can I accomplish this?

#6 Guests

  • Guests

Posted 19 July 2012 - 03:47 PM

Bump