创buildbatch file

我试图创build一个batch file,将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 

如果这是您的batch file的实际内容:

 @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 

那么你需要引用任何文件path与""像这样:

 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编写它,所以也许别人可以帮助你。