PowerShell로 Excel파일을 PDF로 변환하기

-- PowerShell 2011. 6. 15. 18:51
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

$strPath = "D:\TestBed\PowerShell"

$typFormatType = "microsoft.office.interop.excel.xlFixedFormatType" -As [type]
$objXLSFiles = Get-ChildItem -Path $strPath -Include *.xls, *.xlsx -Recurse

$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $false

foreach($objXLSFile in $objXLSFiles)
{
    $strPDFPath = Join-Path -Path $strPath -ChildPath ($objXLSFile.BaseName + ".pdf")
    $objWorkBook = $objExcel.WorkBooks.Open($objXLSFile.FullName, 3)
    $objWorkBook.Saved = $true
    $objWorkBook.ExportAsFixedFormat($typFormatType::xlTypePDF, $strPDFPath)
    $objWorkBook.Close()
}

$objExcel.Quit()

Excel2PDF.ps1

참고) http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/06/save-a-microsoft-excel-workbook-as-a-pdf-file-by-using-powershell.aspx

'-- PowerShell' 카테고리의 다른 글

The VBScript-to-Windows PowerShell Conversion Guide  (0) 2011.06.22
PowerShell로 브라우저 제어  (0) 2011.06.15
PowerShell로 엑셀파일 생성하기  (0) 2011.06.15
Windows PowerShell Quick Reference  (0) 2011.06.15
wbemtest.exe  (0) 2011.06.15
posted by 어린왕자악꿍