Skip to main content
Version: v6.5.0

Export as PDF

Command Description

Export the current worksheet or all worksheets in the workbook as a PDF

Command Prototype

sRet = Excel.ExportPDF(objExcelWorkBook,sheetRange,folderPath,bCover)

Command parameter

parametermandatorytypedefault valueInstructions
objExcelWorkBookTrueexpressionobjExcelWorkBookWorkbook objects returned by the Open Excel Workbook command (Excel. Open) or Bind Excel Workbook command (Excel. BindBook)
sheetRangeTrueenum"Current Sheet"Can convert the current worksheet or all worksheets to PDF
folderPathTruepath''' C:\Users'''Specify the folder to save the PDF file to
bCoverTruebooleanFalseThe default is' No '. When there is a file with the same name, it will be automatically renamed to a new file. The naming format is: concatenate the accumulative numerical suffix after the original name. When set to' Yes', it will overwrite the existing file with the same name

Return result

SRet, Assign the result of running the command to this variable.

Run instance

/*********************************Export to PDF**************************************
Command Prototype:
sRet = Excel.ExportPDF(objExcelWorkBook,sheetRange,folderPath,bCover)
Input Parameters:
objExcelWorkBook -- Workbook object. Note: The workbook object returned by the "Open Excel Workbook" command (Excel.Open) or the "Bind Excel Workbook" command (Excel.BindBook).
sheetRange -- Conversion range. Note: Can convert the current worksheet or all worksheets to PDF.
folderPath -- Output directory. Note: Specify the folder where the PDF file will be saved.
bCover -- Overwrite file. Note: Default is "No". When a file with the same name exists, it will be automatically renamed with an incrementing numeric suffix. When set to "Yes", it will overwrite the existing file with the same name.
Output Parameter:
sRet -- The variable where the output of the function call will be saved.
Notes:
None
********************************************************************************/
Dim sRet = ""
sRet = Excel.ExportPDF(objExcelWorkBook,"Current Sheet",'''C:\Users''',False)
TracePrint(sRet)