Option Explicit Dim hozonsaki Dim filesousa Dim insuu Dim i Const msoFalse = 0 Const msoTrue = -1 Const xlTypePDF = 0 Const xlQualityStandard = 0 Const wdExportFormatPDF = 17 Const wdExportOptimizeForPrint = 0 Const wdExportAllDocument = 0 Const wdExportDocumentContent = 0 Const wdExportCreateWordBookmarks = 2 Const wdDoNotSaveChanges = 0 Const ppSaveAsPDF = 32 Set filesousa = CreateObject("Scripting.FileSystemObject") Set insuu = WScript.Arguments If insuu.Count < 1 Then MsgBox "このスクリプトにファイルをドラッグして使ってね。", vbExclamation + vbSystemModal WScript.Quit End If For i = 0 To insuu.Count - 1 hozonsaki = filesousa.GetParentFolderName(insuu(i)) & ChrW(92) & filesousa.GetBaseName(insuu(i)) & ".pdf" Select Case LCase(filesousa.GetExtensionName(insuu(i))) Case "doc","docx","docm","dot","dotx","dotm" With CreateObject("Word.Application") .Visible = True With .Documents.Open(insuu(i)) .ExportAsFixedFormat hozonsaki, wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportAllDocument, , , _ wdExportDocumentContent, False, False, wdExportCreateWordBookmarks, True, True, False .Close wdDoNotSaveChanges End With .Quit End With Case "xls","xlsx","xlsm","xlsb","xlt","xltx","xltm" With CreateObject("Excel.Application") .Visible = True With .Workbooks.Open(insuu(i)) .ExportAsFixedFormat xlTypePDF, hozonsaki, xlQualityStandard, False, False, , , False .Close False End With .Quit End With Case "ppt","pptx","pptm","pot","potx","potm" With CreateObject("PowerPoint.Application") .Visible = True With .Presentations.Open(insuu(i)) .SaveAs hozonsaki, ppSaveAsPDF, msoTrue .Close End With .Quit End With End Select Next MsgBox "変換完了!", vbInformation + vbSystemModal