Hi,
Goal: To run VBScript using CFexecute using command base script Cscript.exe
Environment: ColdFusion 2021, Windows Server 2019 , 64 bit Machine.
My VB Script(ExcelToPDF.vbs) performs simple office automation .
So first I tried with command line to run ExcelToPDF.VBS.
C:WindowsSystem32 > cscript.exe //nologo D:ExcelToPDF.vbs D:test.xls D:test.pdf
and got expected o/p Success (generates the Excel to PDF file )
Now, I have to see whether CF runs correctly or not.
So I use cfexecute to run ExcelToPDF.VBS.
code:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfoutput>
<h1>Test easyPDF SDK</h1>
<cfset inFile = “C:easypdfexcell.xlsx” />
<cfset outFile = “C:easypdftrst.pdf” />
</cfoutput>
<cfexecute
name=’cscript.exe’
arguments=’C:easypdfExcelToPDF.vbs //Nologo #inFile# #outFile#’
timeout=”500000″/>
</body>
</html>
vb script code:
Dim excelFile, pdfFile
Set oPrinter = CreateObject(“easyPDF.Printer.8”)
Set oPrintJob = oPrinter.ExcelPrintJobEx
oPrintJob.NativeOfficePDF = True
oPrintJob.PrintAllSheets = True
Set objArgs = Wscript.Arguments
excelFile = objArgs(0)
pdfFile = objArgs(1)
oPrintJob.PrintOut excelFile, pdfFile
Set oPrintJob = Nothing
Set oPrinter = Nothing
I’ve got some gossip about Microsoft Office automation.
VBScript is so old-fashioned and sometimes obscure and not readable.
The WPS Office, manufactured by we Chinese, uses JavaScript for the Office automation instead.
BTW, I tend to use Authorware-style presentations more than Powerpoint… I wish that it’ll have a new release or update. But it has been abandoned.
But now Adobe has a software named Captivate…It’s good too. A lil’ bit expensive.
You must be logged in to post a comment.