I'm new to applescript and any help on this would be highly appreciated. I think this would be a good challenge for someone with more skills than me. All that is described has been done in Snow Leopard with MS Office 2011.
I have a list of URLs (starting in cell Q2) and I've got applescript to execute the following series of tasks:
- Open MS Excel
- Create new workbook
- Copy URL from MS Excel cell Q2.
- Paste to Firefox address bar and go.
- Click Firefox menu bar function 'View1'(from an add-on)
- Click Firefox menu bar function 'View2'(from an add-on)
- Click Firefox menu bar function 'Copy all Tables'(from an add-on)
- Create new workbook in Excel
- Paste copied text to new workbook cell A1
- Save new workbook as workbook002.xlsx
- Close workbook
I've put together the script below for this and it works. The trouble is that i cant make it repeat. The repeat function is required to repeat the execution of the whole script, first changing cell Q2 to Q3 and so on up to the point where the last cell contains the value 0 which is the signal to end the loop, and save each workbook with names in a sequential order (workbook002 then workbook003 etc). I don't think the firefox part needs to be changed because the steps are always the same.
Here's the script:
do shell script "open -a /Applications/Microsoft\\ Office\\ 2011/Microsoft\
\ Excel.app ~/Desktop/KospiSection2.xlsx"
tell application "Microsoft Excel"
set sourceBook to workbook "Section2.xlsx"
set sourceRange to get 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 all 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
do shell script "save as -a /Applications/Microsoft\\ Office\\ 2011/Microsoft\\
Excel.app ~/Desktop/workbook002.xlsx"
Sincere thanks if anyone can figure out how to do this. I've been breaking my head over this for a long long time. p.s. If anyone knows a good book on running excel with applescript, please tell me.
Thanks again!