Projet

Général

Profil

Fonctionnalité #14338 » convertExcelToPDF.js

Script VB pour Excel - Cyril VAZQUEZ, 03/07/2020 14:34

 
var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
var docFileName = WScript.Arguments(0);
docFileName = fileSystemObject.GetAbsolutePathName(docFileName);

var objExcel = null;

try {
objExcel = new ActiveXObject("Excel.Application");
objExcel.Visible = false;

var Type = 0; // XlFixedFormatType.xlTypePDF;
var FileName = docFileName.replace(/\.xls[^.]*$/, ".pdf");
var Quality = false;
var IncludeDocProperties = true; // XlFixedFormatQuality .xlQualityStandard // 0

var objDoc = objExcel.Workbooks.Open(docFileName);

objDoc.ExportAsFixedFormat(Type, FileName, Quality, IncludeDocProperties);

objDoc.Close();

//WScript.Echo("Done.");
} finally {
if (objExcel != null) {
objExcel.Quit();
}
}
(2-2/4)