我正在尝试创建一个将Excel文件转换为PDF的批处理文件。我的命令行是否有问题,因为它似乎不起作用:
Dim i As Double
Dim sBatchFile As String
ActiveWorkbook.Save
sBatchFile = "C:\test.bat"
Open sBatchFile For Output As #1
Print #1, "@ECHO OFF"
Print #1, "ECHO Converting Excel Files to PDF, Please wait..."
Print #1, "batchpdf C:\Documents and Settings\Andrew_G\My Documents\Office Docs\Schedule.xls C:\Documents and Settings\Andrew_G\My Documents\Office Docs\TEST1234.pdf"
Close #1
i = Shell(sBatchFile, vbMaximizedFocus)
End Sub
答案 0 :(得分:3)
如果这是批处理文件的实际内容:
@ECHO OFF
ECHO Converting Excel Files to PDF, Please wait...
batchpdf C:\Documents and Settings\Andrew_G\My Documents\Office Docs\Schedule.xls C:\Documents and Settings\Andrew_G\My Documents\Office Docs\TEST1234.pdf
然后你需要用""
引用任何文件pathes:
batchpdf "C:\Documents and Settings\Andrew_G\My Documents\Office Docs\Schedule.xls" "C:\Documents and Settings\Andrew_G\My Documents\Office Docs\TEST1234.pdf"
但我不知道如何用VBA写出来,所以也许其他人可以帮助你。