Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - convert xls to pdf

Reply
 
Old 04-11-2009   #1 (permalink)
Andrea


 
 

convert xls to pdf

Hi guys,
I have to make script to convert xls to pdf files and I'd like to know
if this is possible with powershell.

Thanks very much
Andrew

My System SpecsSystem Spec
Old 04-11-2009   #2 (permalink)
Vadims Podans [MVP]


 
 

Re: convert xls to pdf

mm..I don't sure that it is possible to convert comething to PDF without any
additional software. However I recomend CutePDF Writer which installs as
printer and any file in any program that support printing - you can easy
convert any file to PDF.
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Andrea" <netsecurity@xxxxxx> rakstija zinojuma
"news:1d5393bf-047b-47d1-a1b8-a14ddbfc573b@xxxxxx"...
Quote:

> Hi guys,
> I have to make script to convert xls to pdf files and I'd like to know
> if this is possible with powershell.
>
> Thanks very much
> Andrew
My System SpecsSystem Spec
Old 04-11-2009   #3 (permalink)
Robert Robelo


 
 

Re: convert xls to pdf

You can export Excel workbooks to Fixed Format -PDF or XPS- with _Office 2007_ (the ExportAsFixedFormat Method was added to Office 2007) and the free Add-In you can download here:
http://r.office.microsoft.com/r/rlidMSAddinPDFXPS

Then, simply create an instance of Excel, open the workbook you want to export and export it:

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# -<Sample.ps1>-
$ExcelFile = 'C:\Excel\file.xls'
$Destination = 'C:\file.pdf'

# Microsoft.Office.Interop.Excel.XlFixedFormatType
$xlTypePDF = 0
$xlTypeXPS = 1

# Microsoft.Office.Interop.Excel.XlFixedFormatQuality
$xlQualityStandard = 0
$xlQualityMinimum = 1

$readOnly = $true
$save = $false

$xl = new-object -c excel.application

# open workbook read-only
$wb = $xl.workbooks.Open($ExcelFile,$null,$readOnly)

$XlFixedFormatType = $xlTypePDF
$XlFixedFormatQuality = $xlQualityStandard

# export to PDF fixed format
$wb.ExportAsFixedFormat($XlFixedFormatType, $Destination,`
$XlFixedFormatQuality)

# close workbook without saving
$wb.close($save)

# cleanup
$xl.quit()
$xl, $wb | % {
[void][Runtime.InteropServices.Marshal]::releaseComObject($_)
}

--
Robert
My System SpecsSystem Spec
Old 04-11-2009   #4 (permalink)
Alex K. Angelopoulos


 
 

Re: convert xls to pdf

Whew. Glad you posted; I was still working on my realllly complicated
explanation of installing fake GhostScript drivers and automating print
output. : )

"Robert Robelo" <Kiron@xxxxxx> wrote in message
news:OHb5eYtuJHA.1300@xxxxxx
Quote:

> You can export Excel workbooks to Fixed Format -PDF or XPS- with _Office
> 2007_ (the ExportAsFixedFormat Method was added to Office 2007) and the
> free Add-In you can download here:
> http://r.office.microsoft.com/r/rlidMSAddinPDFXPS
>
> Then, simply create an instance of Excel, open the workbook you want to
> export and export it:
>
> # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
> # -<Sample.ps1>-
> $ExcelFile = 'C:\Excel\file.xls'
> $Destination = 'C:\file.pdf'
>
> # Microsoft.Office.Interop.Excel.XlFixedFormatType
> $xlTypePDF = 0
> $xlTypeXPS = 1
>
> # Microsoft.Office.Interop.Excel.XlFixedFormatQuality
> $xlQualityStandard = 0
> $xlQualityMinimum = 1
>
> $readOnly = $true
> $save = $false
>
> $xl = new-object -c excel.application
>
> # open workbook read-only
> $wb = $xl.workbooks.Open($ExcelFile,$null,$readOnly)
>
> $XlFixedFormatType = $xlTypePDF
> $XlFixedFormatQuality = $xlQualityStandard
>
> # export to PDF fixed format
> $wb.ExportAsFixedFormat($XlFixedFormatType, $Destination,`
> $XlFixedFormatQuality)
>
> # close workbook without saving
> $wb.close($save)
>
> # cleanup
> $xl.quit()
> $xl, $wb | % {
> [void][Runtime.InteropServices.Marshal]::releaseComObject($_)
> }
>
> --
> Robert
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Convert .Swf to .Exe General Discussion
Vb6 Convert .NET General
convert vhs to Dvd Chillout Room
RE: Convert VHD to ISO? Virtual PC
Convert EML to DBX? Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46