$xlTypePDF = 0 $iPath = "D:\Desktop\*" $oPath = "D:\Desktop\test" $ext = "xlsx" $targetSheet = "sheet1" $targetBooks = Get-ChildItem -Path $iPath -Include "*.$ext" $excel = new-object -comObject "Excel.Application" $excel.Visible = $true foreach($book in $targetBooks){ $excel.Workbooks.Open($book.fullname) | Out-Null $outFileName = (Join-Path $oPath $book.name).Replace($ext,"pdf") $excel.ActiveWorkbook.WorkSheets.Item($targetSheet).ExportAsFixedFormat($xlTypePDF,$outFileName) $excel.ActiveWorkbook.Close($false) #保存しないで閉じる } $excel.Quit() |
0 件のコメント:
コメントを投稿