创建批处理文件
我正在尝试创建一个批处理文件,将 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
I'm trying to create a batch file that will convert an Excel file to a PDF. Is there something wrong with my command line because it doesn't seem to work:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是批处理文件的实际内容:
那么您需要用
""
引用任何文件路径,如下所示:但我不知道如何用 VBA 准确编写它,所以也许其他人可以帮助你。
If this is the actual content of your batch file:
then you need to quote any file pathes with
""
like this:But I don't know how to exactly write it with VBA, so maybe someone else can help you with that.