dnf999 Posted October 25, 2009 Share Posted October 25, 2009 Hi All, I'm having a problem where I cannot get specific Excel sheets to open and then text pasted to them dependent on the For loop value. i.e. if the value is below 10000 then open up a specific .xlsm sheet and run a macro, if the value is above 10000 then open a different .xlsm sheet and then run a macro. But when I try and run the below part of the script, it only opens the first .xlsm sheet and does not go to the other sheets, even though the $i value > 10000 For $i = 1 to 40000 Step 1 Select Case $i <= 10000 WinActivate("SHR_RA_Transactions_00001_10000") Send("!{F8}") Send("{ENTER}") Case $i >=10001 and $i<= 20000 WinActivate("SHR_RA_Transactions_10001_20000") Send("!{F8}") Send("{ENTER}") Case $i >=20001 and $i<= 30000 WinActivate("SHR_RA_Transactions_20001_30000") Send("!{F8}") Send("{ENTER}") Case $i >=30001 and $i<= 40000 WinActivate("SHR_RA_Transactions_30001_40000") Send("!{F8}") Send("{ENTER}") EndSelect Next Please can anybody tell me if I am doing anything incorrect with the WinActiviate statement (I've tried WinWait but that doesn't work either..) Thanks!! Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 25, 2009 Share Posted October 25, 2009 Hi All, I'm having a problem where I cannot get specific Excel sheets to open and then text pasted to them dependent on the For loop value. i.e. if the value is below 10000 then open up a specific .xlsm sheet and run a macro, if the value is above 10000 then open a different .xlsm sheet and then run a macro. But when I try and run the below part of the script, it only opens the first .xlsm sheet and does not go to the other sheets, even though the $i value > 10000 For $i = 1 to 40000 Step 1 Select Case $i <= 10000 WinActivate("SHR_RA_Transactions_00001_10000") Send("!{F8}") Send("{ENTER}") Case $i >=10001 and $i<= 20000 WinActivate("SHR_RA_Transactions_10001_20000") Send("!{F8}") Send("{ENTER}") Case $i >=20001 and $i<= 30000 WinActivate("SHR_RA_Transactions_20001_30000") Send("!{F8}") Send("{ENTER}") Case $i >=30001 and $i<= 40000 WinActivate("SHR_RA_Transactions_30001_40000") Send("!{F8}") Send("{ENTER}") EndSelect Next Please can anybody tell me if I am doing anything incorrect with the WinActiviate statement (I've tried WinWait but that doesn't work either..) Thanks!! You can test @error after WinActivate() to see if the correct window was activated before proceeding. Most likely your window specification is failing, so WinActivate() is doing nothing, leaving the currently active window unchanged. Check the windows with the AU3Info.exe window info tool to see if you really have the title, or just a document name, etc. If you get the handles to those windows before starting the loop and use those instead of titles it will be much more reliable. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
herewasplato Posted October 25, 2009 Share Posted October 25, 2009 ... I cannot get specific Excel sheets to open ...~~~... it only opens the first .xlsm sheet and does not go to the other sheets, ...Welcome to the forum.Are these worksheets within one file or different spreadsheets files?> ... it only opens the first .xlsm worksheet and does not go to the other worksheets, ...or> ... it only opens the first .xlsm spreadsheet and does not go to the other spreadsheets, ...or.................? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now