Skip to content

Instantly share code, notes, and snippets.

@kastnerp
Created November 14, 2020 19:30
Show Gist options
  • Save kastnerp/b131f022c16f7e35fb1223907daa3942 to your computer and use it in GitHub Desktop.
Save kastnerp/b131f022c16f7e35fb1223907daa3942 to your computer and use it in GitHub Desktop.
Windows script: Converting all *.pptx in a folder to *.pdf
REM https://stackoverflow.com/questions/45348197/convert-multiple-powerpoint-files-to-pdf-using-cmd
@if (@X)==(@Y) @end /* JScript comment
@echo off
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
var source=WScript.Arguments.Item(0);
var target=WScript.Arguments.Item(1);
PP = new ActiveXObject("PowerPoint.Application");
PRSNT = PP.presentations.Open(source,0,0,0)
//PRSNT.SaveCopyAs(target,32);
//https://msdn.microsoft.com/en-us/vba/powerpoint-vba/articles/ppsaveasfiletype-enumeration-powerpoint
PRSNT.SaveAs(target,32);
PRSNT.Close();
PP.Quit();
REM https://stackoverflow.com/questions/45348197/convert-multiple-powerpoint-files-to-pdf-using-cmd
@echo off
set "ppt_dir=%~dp0"
for %%a in ("%ppt_dir%\*pptx" "%ppt_dir%\*ppt") do (
call pptx2pdf.bat "%%~fa" "%%~dpna.pdf"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment