FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Excel to pdf
Posts: 199
Joined: Fri Apr 18, 2008 04:21 PM
Excel to pdf
Posted: Mon Jan 23, 2012 11:35 PM

Alguien me puede ayudar.

Hola a todos como puedo pasar una hoja de excel a PDF desde xharbour/FWH.

Atentamente
Julio Ponce

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Excel to pdf
Posted: Tue Jan 24, 2012 10:48 AM
Try this

Code (fw): Select all Collapse
#Include "FiveWin.ch"

#DEFINE  xlTypePDF  0
//-----------------------//
Function Main()
    Local oExcel,cMicSoftPdfDllFile,cPdfFileName
                                
    oExcel:=CreateObject("Excel.Application")
    
    if Val(oExcel:Version) < 12
        MsgInfo("You need excel 2007 or above")
        oExcel:Quit()
        Return .F.
    Endif
    
    cMSoftPdfDllFile:=GetEnv("CommonProgramFiles")+"\Microsoft Shared\OFFICE"+;
                            Left(oExcel:Version,2)+"\EXP_PDF.DLL"

    If !File(cMSoftPdfDllFile)
        MsgInfo("Microsoft Office PDF add-in is not installed on your PC")
        oExcel:Quit()
        Return .F.
    Endif  
    
    oExcel:Workbooks:Open("D:\YourExcelFile.xlsx")
   
    cPdfFileName:="D:\Test.Pdf"    
    oExcel:WorkSheets(1):ExportAsFixedFormat( xlTypePDF,cPdfFileName)
                                      
    oExcel:Quit() 
    MsgInfo("Created pdf "+cPdfFileName)                                       

Return NIL

Regards
Anser
Posts: 199
Joined: Fri Apr 18, 2008 04:21 PM
Re: Excel to pdf
Posted: Tue Jan 24, 2012 02:53 PM

Gracias

Tengo Office 2010 funcionara?

estoy haciendo el intento y me dice que no esta instalado el ADDIN pero lo buso y si esta la dll.

Atentamente
Julio Ponce

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Excel to pdf
Posted: Wed Jan 25, 2012 04:31 AM

As I don't have Office 2010 here, I have not tried. This is working fine with Office 2007.

Did you manually check the path for the DLL file ie C:\Program Files\Common Files\Microsoft shared\OfficeXX\EXP_PDF.DLL

Regards
Anser

Continue the discussion