Created
February 24, 2015 17:23
-
-
Save ElectricWarr/43fd4ade56be33dc1ecf to your computer and use it in GitHub Desktop.
This file contains 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
Function ExcelToPDF ($workbook,$PDFdir) { | |
# Exports all worksheets of a PDF (except "Report" and "Template") | |
#Function Variables | |
[string] $filePath | |
#Set as saved | |
$workbook.Saved = $true | |
$xlFixedFormat = "Microsoft.Office.Interop.Excel.xlFixedFormatType" -as [type] | |
ForEach ($ws In $workbook.worksheets) { | |
If (!(($ws.Name -eq "Template") -or ($ws.Name -eq "Report"))) { | |
$filePath = Join-Path -Path $PDFdir -ChildPath ($ws.Name + ".pdf") | |
$ws.ExportAsFixedFormat($xlFixedFormat::xlTypePDF, $filePath) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment