batmanbbs 老师好! 在我这又运行不了,又抄错了那里? Sub 批量转换Word文档为PDF() Dim myPath As String WithApplication.FileDialog(msoFileDialogFolderPicker) If .Show Then myPath =.SelectedItems(1) & "\" Else Exit Sub End With Dim oFolder, oFile As Object, myDoc AsDocument Set oFolder =CreateObject("Scripting.FileSystemObject").GetFolder(myPath) For Each oFile In oFolder.Files myPath = LCase(oFile.Path) If myPath Like "*.doex" OrmyPath Like "*.doc" Then Set myDoc =Documents.Open(FileName:=myPath, ReadOnly:=True) myPath = Left(myPath,InStrRev(myPath, ".")) & "pdf" myDoc.ExportAsFixedFormatOutputFileName:=myPath, _ ExportFormat:=wdExportFormatPDF myDoc.Close End If Next oFile Set oFolder = Nothing Set oFile = Nothing Set myDoc = Nothing End Sub
|