Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Change Agent

macrumors regular
Original poster
Oct 24, 2018
206
15
Applescript to batch convert Excel files to PDF (or Automator)

I need to translate hundreds of Xcel files to PDF. I have been trying stuff but with no result. Does anybody have a script handy I can get?

Thanks.
 
If you install LibreOffice, the solution here…


…actually works but I don't know if you're going to get the results you want.

For instance…it will convert each "sheet" to a separate page but the name of the sheet doesn't show.
 
If you install LibreOffice, the solution here…


…actually works but I don't know if you're going to get the results you want.

For instance…it will convert each "sheet" to a separate page but the name of the sheet doesn't show.
Thanks, not an option as far as I see.
 
Thanks. I have more than 500 MSExcel files to convert. the step to go to OO etc. seems over the top and I like to find a easeir solution.

Maybe I'm wrong but sounds to me like you don't understand the procedure…unless you're saying installing LibreOffice is too much for you to handle.

The Terminal command doesn't even require you that you open LibreOffice or convert anything to the ".odt" format. You'd use "*.xlsx", or whatever extension is on your Excel files, in the command.

Also, you could create a Folder Action with Automator that would run the command on Excel files you drop into the folder.
 
Indeed I do not understand the instructions. and do not understand how it would work. all to cryptic for me.
 
  1. install libreoffe (use the default install).
  2. have the excel files in some folder on your Mac.
  3. open Terminal on your Mac.
  4. copy: /Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nologo --convert-to pdf and paste it into the terminal window (space after »… pdf « at the end!).
  5. Drag the icon of the folder which contains your excel files onto the terminal window.
  6. at this point the input in the terminal should look like: /Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nologo --convert-to pdf /whatever/the/path/to/the/folder/with/the/excelstuff/you/drop/is/
  7. type and add *.xls (space before » *.xls!«) and press return.

EDIT: here is a solution using Applescript delivering the same. Other options are, according to my search engine of choice, available. 🤓
 
Last edited:
aha! Thanks. for translating, that I can understand. will test later when on the machine.
 
Ok this is what i get in Terminal, but get an error.

Code:
/Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nologo --convert-to pdf/Users/e/Desktop/Invoices/444\ copy *.xls

error = no matches found: *.xls
 
Ok this is what i get in Terminal, but get an error.

Code:
/Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nologo --convert-to pdf/Users/e/Desktop/Invoices/444\ copy *.xls

error = no matches found: *.xls
You forgot to press space between pdf and the folder
Code:
/Applications/LibreOffice.app/Contents/MacOS/soffice --invisible --nologo --convert-to pdf /Users/e/Desktop/Invoices/444\ copy *.xls
 
you have space in folder names? in that case you have to put the path to the excel files into quotes: … --convert-to pdf "pdf/Users/e/Desktop/Invoices/444\ copy" *.xls
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.