我正在尝试将给定路径中的所有pptx文件转换为pdf文件。
我的代码:
datasource
错误消息
Sub pptxtopdf()
Dim ppt As Object
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
On Error Resume Next
Set ppt = GetObject(, "PowerPoint.Application")
If ppt Is Nothing Then
Set ppt = CreateObject("PowerPoint.Application")
End If
On Error GoTo 0
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("P:\Operations\Data & Deliverables\Projects\Amica\presentation_workspace\1_ spring 2015\Presentations\Volvo")
i = 1
'loops through each file in the directory
For Each objFile In objFolder.Files
Set WDReport = ppt.Presentations.Open(objFile.Path)
Dim FileName2 As String
FileName2 = Replace(objFile.Path, "pptx", "pdf")
'WDReport.ExportAsFixedFormat FileName2, ppFixedFormatTypePDF
WDReport.SaveAs FileName2, ppSaveAsPDF
WDReport.Close
ppt.Quit
Set ppt = Nothing
Set WDReport = Nothing
i = i + 1
Next objFile
End Sub
看不出我做错了什么?
与此问题相同,但解决方案对我无效 - Excel macro to save pptx as pdf; error with code
答案 0 :(得分:7)
您是后期绑定$('#NodeList').height("-=100");
draw();
,因此其枚举值不会在全局VBA名称空间中公开或可用。
由于您尚未添加PowerPoint.Application
来警告您未声明的变量,因此使用未声明的option explicit
不会导致错误,但没有任何价值。
添加:
ppSaveAsPDF
到模块顶部,为const ppSaveAsPDF as long = 32
提供预期值。