function
Convert-ExcelToPdf
{
param
(
[io.fileinfo]
$DocPath
,
[string]
$PdfPath
)
$xlFixedFormat
= “Microsoft.Office.Interop.Excel.xlFixedFormatType”
-as
[type]
$objExcel
=
New-Object
-ComObject
excel.application
$workbook
=
$objExcel
.workbooks.open(
$DocPath
.fullname, 3)
$workbook
.ActiveSheet.PageSetup.Orientation = 2
$objExcel
.PrintCommunication =
$false
$workbook
.ActiveSheet.PageSetup.FitToPagesTall =
$false
$workbook
.ActiveSheet.PageSetup.FitToPagesWide = 1
$objExcel
.PrintCommunication =
$true
$workbook
.Saved =
$true
$workbook
.ExportAsFixedFormat(
$xlFixedFormat
::xlTypePDF,
$PdfPath
)
$objExcel
.Workbooks.close()
$objExcel
.Quit()
}