Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
776 views
in Technique[技术] by (71.8m points)

pdf generation - What is the FileType number for PDF in Excel 2007 that is needed to save a file as PDF through the API?

I need to call a function in order to save an Excel workbook. I installed the PDF save addon for Excel 2007 but now I need to know what the number code is for the file format for when I save the excel file.

An example of the excel file format numbers can be found here.

http://www.dailydoseofexcel.com/archives/2006/10/29/saveas-in-excel-2007/

FileExtStr = ".xlsb": FileFormatNum = 50
FileExtStr = ".xlsx": FileFormatNum = 51
FileExtStr = ".xlsm": FileFormatNum = 52
FileExtStr = ".xls": FileFormatNum = 56
FileExtStr = ".csv": FileFormatNum = 6
FileExtStr = ".txt": FileFormatNum = -4158
FileExtStr = ".prn": FileFormatNum = 36

I need the one for the .pdf ending.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Check out the Workbook.ExportAsFixedFormat method:

ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF 
    FileName:=“sales.pdf” 
    Quality:=xlQualityStandard 
    DisplayFileAfterPublish:=True 

This method should be preferred over using SaveAs because it also allows specifying all PDF / XPS options.

Note: This method has been added to the Excel object model with Excel 2007 and requires the Save as PDF or XPS Add-in for 2007 Microsoft Office programs to be installed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...