I've made a workbook in Excel for Windows, and am now trying to get it to work on Excel for Mac. One option I have given the user is to output certain sheets into a single PDF file. Due to a problem with Excel for Mac, I've had to write code to output each worksheet as a separate PDF file. I now want to merge them together into one PDF file.
I found a blog that explains how to do this in Terminal.
http://cmdlinetips.com/2016/03/how-to-join-pdf-files-in-mac-on-terminal/
I tested it, and figured out how to make it work on my Mac running El Capitan (10.11). In Terminal, I type this and it works:
/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o /Users/mattc/Documents/NewPDF.pdf /Users/mattc/Documents/1.pdf /Users/mattc/Documents/2.pdf
Now I want to make it so it does this via VBA code, so the user doesn't have to worry about opening up Terminal and doing it manually. I'm using Excel 2011 for Mac, ver 14.7.7.
I have almost no experience with Mac, so the only things I have tried are things I've seen in other forum posts about possibly how to do it.
I have tried the following, but nothing has worked so far:
In all cases, I get Runtime error 5: invalid procedure call or argument.
Anyone have any idea how to make this work?
I found a blog that explains how to do this in Terminal.
http://cmdlinetips.com/2016/03/how-to-join-pdf-files-in-mac-on-terminal/
I tested it, and figured out how to make it work on my Mac running El Capitan (10.11). In Terminal, I type this and it works:
/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o /Users/mattc/Documents/NewPDF.pdf /Users/mattc/Documents/1.pdf /Users/mattc/Documents/2.pdf
Now I want to make it so it does this via VBA code, so the user doesn't have to worry about opening up Terminal and doing it manually. I'm using Excel 2011 for Mac, ver 14.7.7.
I have almost no experience with Mac, so the only things I have tried are things I've seen in other forum posts about possibly how to do it.
I have tried the following, but nothing has worked so far:
Code:
Dim myMacScript As String
Dim Temp
'ATTEMPT [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL]
myMacScript = "do shell script ""/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o /Users/mattc/Documents/NewPDF.pdf /Users/mattc/Documents/1.pdf /Users/mattc/Documents/2.pdf"""
Temp = MacScript(myMacScript)
'Instead of the above line, I also tried this instead:
MacScript (myMacScript)
'but that did not work either.
'ATTEMPT [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=2]#2[/URL]
myMacScript = "run script (""/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o /Users/mattc/Documents/NewPDF.pdf /Users/mattc/Documents/1.pdf /Users/mattc/Documents/2.pdf"")"
Temp = MacScript(myMacScript)
'ATTEMPT [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=3]#3[/URL]
myMacScript = "run script (""/System/Library/Automator/Combine\ PDF\ Pages.action/Contents/Resources/join.py -o /Users/mattc/Documents/NewPDF.pdf /Users/mattc/Documents/1.pdf /Users/mattc/Documents/2.pdf"" as alias)"
Temp = MacScript(myMacScript)
In all cases, I get Runtime error 5: invalid procedure call or argument.
Anyone have any idea how to make this work?