Created
July 16, 2010 04:00
-
-
Save masanobuimai/477904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim tmpExcel, tmpWord, tmpPPT, I, pdfFile, waitTime | |
waitTime = 10000 | |
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") | |
Set objArgs = WScript.Arguments | |
For I = 0 to objArgs.Count - 1 | |
If objFSO.FileExists(objArgs(I)) Then | |
Set file = objFSO.getFile(objArgs(I)) | |
filter(file) | |
End If | |
If objFSO.FolderExists(objArgs(I)) Then | |
Set folder = objFSO.getFolder(objArgs(I)) | |
For Each file in folder.Files | |
filter(file) | |
Next | |
End If | |
Next | |
Function filter(file) | |
If file.Type = "Microsoft Excel ワークシート" Then | |
tmpExcel = tmpExcel & file.Path & ";" | |
ElseIf file.Type = "Microsoft Word 文書" Then | |
tmpWord = tmpWord & file.Path & ";" | |
ElseIf file.Type = "Microsoft PowerPoint プレゼンテーション" Then | |
tmpPPT = tmpPPT & file.Path & ";" | |
End If | |
End Function | |
Dim excelList, wordList, pptList | |
excelList = Split(tmpExcel, ";") | |
wordList = Split(tmpWord, ";") | |
pptList = Split(tmpPPT, ";") | |
Set pdfApp = WScript.CreateObject("Bullzip.PDFPrinterSettings") | |
Set objNetwork = WScript.CreateObject("WScript.Network") | |
objNetwork.SetDefaultPrinter pdfApp.GetPrinterName | |
Set excelApp = WScript.CreateObject("Excel.Application") | |
For I = 0 To UBound(excelList) - 1 | |
pdfFile = Left(excelList(I), Len(excelList(I)) - 4) & ".pdf" | |
With pdfApp | |
.Init | |
.SetValue "Output", pdfFile | |
.SetValue "confirmoverwrite", "no" | |
.SetValue "showpdf", "no" | |
.SetValue "showsettings", "never" | |
.WriteSettings True | |
End With | |
Set wb = excelApp.Workbooks.Open(excelList(I)) | |
wb.PrintOut | |
WScript.Sleep waitTime | |
wb.Close False, False | |
Next | |
excelApp.Quit | |
Set wordApp = WScript.CreateObject("Word.Application") | |
For I = 0 To UBound(wordList) - 1 | |
pdfFile = Left(wordList(I), Len(wordList(I)) - 4) & ".pdf" | |
With pdfApp | |
.Init | |
.SetValue "Output", pdfFile | |
.SetValue "confirmoverwrite", "no" | |
.SetValue "showpdf", "no" | |
.SetValue "showsettings", "never" | |
.WriteSettings True | |
End With | |
Set doc = wordApp.Documents.Open(wordList(I)) | |
doc.PrintOut | |
WScript.Sleep waitTime | |
doc.Close False, False | |
Next | |
wordApp.Quit | |
Set pptApp = WScript.CreateObject("PowerPoint.Application") | |
If pptApp.Version >= 9 Then | |
pptApp.Visible = True | |
End If | |
For I = 0 To UBound(pptList) - 1 | |
pdfFile = Left(pptList(I), Len(pptList(I)) - 4) & ".pdf" | |
With pdfApp | |
.Init | |
.SetValue "Output", pdfFile | |
.SetValue "confirmoverwrite", "no" | |
.SetValue "showpdf", "no" | |
.SetValue "showsettings", "never" | |
.WriteSettings True | |
End With | |
Set ppt = pptApp.Presentations.Open(pptList(I)) | |
With ppt | |
.PrintOptions.OutputType = 2 | |
.PrintOptions.FitToPage = True | |
.PrintOptions.FrameSlides = True | |
.PrintOut | |
End With | |
WScript.Sleep waitTime | |
ppt.Close | |
Next | |
pptApp.Quit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment