export PDF from excel

export PDF from excel

Postby damianodec » Wed Jul 05, 2023 8:23 am

Hi,
I have my exe that makes a file excel...
Code: Select all  Expand view

oExcel := CREATEOBJECT( "Excel.Application" )
oBook := oExcel:Workbooks() 
oWorkBook := oExcel:Workbooks:Add()
oWorkBook:Sheets("Foglio1"):Select()   
oWorkBook:Sheets("Foglio1"):Name := "Dati"
...
 


then I save this file and export to pdf...

Code: Select all  Expand view

oExcel:WorkSheets(1):PageSetup:PrintTitleRows := "$1:$2"
oExcel:WorkSheets(1):PageSetup:CenterFooter := "Pagina &P di &N"   
oExcel:WorkSheets(1):PageSetup:Orientation := 2
oExcel:WorkSheets(1):PageSetup:PaperSize := 9          
oExcel:WorkSheets(1):PageSetup:Zoom := .f.             
oExcel:WorkSheets(1):PageSetup:FitToPagesWide := 1 
oExcel:WorkSheets(1):PageSetup:FitToPagesTall := .f.       
oExcel:WorkSheets(1):ExportAsFixedFormat( xlTypePDF,cFilePDF)      

oWorkBook:SaveAs(Filename:=cFileMail, FileFormat:=52)  
 

this exe is on a server and Windows Task scheduler run this exe every night (02.00).

when I run this exe by my double click mouse that works fine but when it run by Windows Task scheduler I get this error:

Application
===========
Path and name: C:\batchDcasta\LAVCEN.EXE (64 bits)
Size: 5,244,928 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 19.06
C compiler version: Microsoft Visual C++ 19.20.27508 (64-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 25 secs
Error occurred at: 05-07-2023, 06:00:35
Error description: (DOS Error -2147352567) WINOLE/1006 Unable to set the PaperSize property for the PageSetup class. (0x800A03EC): Microsoft Excel
Args:
[ 1] = N 9

Stack Calls
===========
Called from: => TOLEAUTO:_PAPERSIZE( 0 )
Called from: lavcen.prg => MAIN( 657 )

any solution?

thanks
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests