Applescript Loop/Repeat Functions in Excel with Firefox -


i'm new applescript , on highly appreciated. think challenge more skills me. described has been done in snow leopard ms office 2011.

i have list of urls (starting in cell q2) , i've got applescript execute following series of tasks:

  1. open ms excel
  2. create new workbook
  3. copy url ms excel cell q2.
  4. paste firefox address bar , go.
  5. click firefox menu bar function 'view1'(from add-on)
  6. click firefox menu bar function 'view2'(from add-on)
  7. click firefox menu bar function 'copy tables'(from add-on)
  8. create new workbook in excel
  9. paste copied text new workbook cell a1
  10. save new workbook workbook002.xlsx
  11. close workbook

i've put script below , works. trouble cant make repeat. repeat function required repeat execution of whole script, first changing cell q2 q3 , on point last cell contains value 0 signal end loop, , save each workbook names in sequential order (workbook002 workbook003 etc). don't think firefox part needs changed because steps same.

here's script:

do shell script "open -a /applications/microsoft\\ office\\ 2011/microsoft\ \ excel.app ~/desktop/kospisection2.xlsx" tell application "microsoft excel" set sourcebook workbook "section2.xlsx" set sourcerange range "q2" of sheet 1 of sourcebook copy range sourcerange end tell tell application "firefox" activate tell application "system events" tell process "firefox" click menu item "pastego" of menu "tools" of menu bar 1 delay 3 click menu item "view1" of menu "view" of menu bar 1 delay 10 click menu item "view2" of menu "view" of menu bar 1 delay 2 click menu item "copy tables (2)" of menu "edit" of menu bar 1 delay 3 click menu item "close tab" of menu file of menu bar 1 end tell end tell end tell tell application "microsoft excel" make new workbook delay 2 tell active sheet of active workbook paste worksheet destination range "a1" delay 2 end tell end tell shell script "save -a /applications/microsoft\\ office\\ 2011/microsoft\\ excel.app ~/desktop/workbook002.xlsx" 

sincere if can figure out how this. i've been breaking head on long long time. p.s. if knows book on running excel applescript, please tell me.

thanks again!

all right... need things :

  • identify recursion, i.e. place program changes... mentionned :

range "q2" of sheet 1 of sourcebook should evolve in range "q3" of sheet 1 of sourcebook

in applescript terms, write line this:

set sourcerange range ("q" & i) of sheet 1 of sourcebook 

and work on "i" variable. note "i" variable appear in name of workbook

"workbook002.xlsx" becomes ("workbook00" & & ".xlsx")

  • you must identify recursion stops. meaning, in our case, max value of "i". let's it's 20 our example. code becomes :

tell application "microsoft excel"

set sourcebook workbook "section2.xlsx"  repeat 2 thru 20    set sourcerange range ("q" & i) of sheet 1 of sourcebook    ...    set outputfilename "workbook00" & & ".xlsx" -- there should work on name looks expect, that's thing)    save workbook active workbook filename ({path desktop folder string, outputfilename} string) overwrite -- keep 'save as' action within loop, , within "tell excel"         end -- repeat 

end tell

this should trick...


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -