使用 CMD 将多个 PowerPoint 文件转换为 PDF

Bas*_*ude 1 command-line cmd batch-file

有什么方法可以使用 Windows 命令行将文件夹中的多个 PowerPoint 文件转换为 PDF?

npo*_*aka 9

它不是故障安全的(您可以添加文件存在检查等)。将其另存为.bat

@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();
Run Code Online (Sandbox Code Playgroud)

第一个参数是 powerpoint 文件,第二个参数是要保存它的新文件。有关演示文稿对象的更多信息

下一步是处理文件(如果之前的脚本是另存为ppt2pdf.bat):

@echo off
::change the locataion in the line bellow
set "ppt_dir=c:\ppts"
for %%a in ("%ppt_dir%\*pptx" "%ppt_dir%\*ppt") do (
  call ppt2pdf.bat "%%~fa" "%%~dpna.pdf"
)
Run Code Online (Sandbox Code Playgroud)