Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Batch convert NeoOffice spreadsheets to Excel Apps
Having recently needed to convert a large pile of .ods and .xlsx to .xls for uniformity, I created the following AppleScript. To make it, I tried using Automator to record actions, but couldn't edit the list of actions recorded to make it generic, rather than specific to the document that was on top.

However, I found that if you select a number of recorded actions from inside the 'recorded actions' box in Automator and drag them into the empty space below the command, it will generate an AppleScript of those actions.

I was also having problems with the action timing out during the switch and open save dialog. I fixed this by deleting the on error event, so that the command would continue to try until the timeout elapsed. That seemed to work.

Here's the script:
on run {}
  
  -- Click "NeoOffice" in the Dock.
  set timeoutSeconds to 0.3
  set uiScript to "click UI Element \"NeoOffice\" of list 1 of application process \"Dock\""
  my doWithTimeout(uiScript, timeoutSeconds)
  
  -- Press ⇧⌘S
  delay 0.2
  set timeoutSeconds to 1
  set uiScript to "keystroke \"s\" using {shift down, command down}"
  my doWithTimeout(uiScript, timeoutSeconds)
  
  -- Make a selection from the popupbutton.
  delay 0.2
  set timeoutSeconds to 1
  set uiScript to "click pop up button 1 of group 1 of window \"Save\" of application process \"NeoOffice\""
  my doWithTimeout(uiScript, timeoutSeconds)
  
  -- Microsoft Excel 97/2000/XP (.xls)
  delay 0.2
  set timeoutSeconds to 0.2
  set uiScript to "click menu item \"Microsoft Excel 97/2000/XP (.xls)\" of menu 1 of pop up button 1 of group 1 of window \"Save\" of application process \"NeoOffice\""
  my doWithTimeout(uiScript, timeoutSeconds)
  
  -- Click the "Save" button.
  delay 0.2
  set timeoutSeconds to 0.2
  set uiScript to "click UI Element \"Save\" of window \"Save\" of application process \"NeoOffice\""
  my doWithTimeout(uiScript, timeoutSeconds)
  
  -- Press ⌘W
  delay 0.2
  set timeoutSeconds to 0.2
  set uiScript to "keystroke \"w\" using command down"
  my doWithTimeout(uiScript, timeoutSeconds)
  
end run

on doWithTimeout(uiScript, timeoutSeconds)
  set endDate to (current date) + timeoutSeconds
  repeat
    try
      run script "tell application \"System Events\"
" & uiScript & "
end tell"
      exit repeat
    on error errorMessage
      if ((current date) > endDate) then
        
      end if
    end try
  end repeat
end doWithTimeout

[crarko adds: I haven't tested this one.]
    •    
  • Currently 3.50 / 5
  You rated: 5 / 5 (2 votes cast)
 
[3,888 views]  

Batch convert NeoOffice spreadsheets to Excel | 3 comments | Create New Account
Click here to return to the 'Batch convert NeoOffice spreadsheets to Excel' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Batch convert NeoOffice spreadsheets to Excel
Authored by: xhinter on Apr 07, '11 09:40:34AM
However, I found that if you select a number of recorded actions from inside the 'recorded actions' box in Automator and drag them into the empty space below the command, it will generate an AppleScript of those actions.
Could you please elaborate a little bit more on this, indicating OS version?

[ Reply to This | # ]
Batch convert NeoOffice spreadsheets to Excel
Authored by: Quatch on Apr 09, '11 03:00:11PM

Most recent, 10.6.7

I simply recorded an action then selected the steps, omitting the ones I didn't want, and dragged them to a blank spot in the automator window right below the recorded action action. It then inserted an applescript action containing the above code, which I have only manually tuned slightly.



[ Reply to This | # ]
Re: Batch convert NeoOffice spreadsheets to Excel
Authored by: Uncle Asad on Apr 07, '11 01:47:28PM
Many moons ago, I used the "BatchConv" macro to do this sort of thing within NeoOffice. Depending on what your specific needs are, it may be a better fit: http://oooconv.free.fr/batchconv/batchconv_en.html (You'll have to modify the Macro security settings in the Security preferences to allow macros to run in untrusted sources, or whitelist the converter document as a trusted source.)

[ Reply to This | # ]