FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Re: Error de GetActiveObject solamente con FWH (SOLVED)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH (SOLVED)
Posted: Sun Sep 04, 2011 01:26 AM
Antonio, esta funcion esta fallando y hace que las app se bloqueen al llegar a las line donde se encuentre, esto sucede tanto con xharbour.org ultima version y xharbour.com si se acompaña de las lib de fwh, por si solos ambos compiladores ejecutan bien la linea:
prueba este ejemplo con fwh y luego sin fwh
Code (fw): Select all Collapse
#INCLUDE "Fivewin.ch"

#translate Alert( <msg> [, <opt,...>] )  => MessageBox( 0, <msg>, "xHarbour OleDemo", 0 )

#define CRLF Chr( 13 ) + Chr( 10 )


//--------------------------------------------------------------------

PROCEDURE MAIN()

   LOCAL oExcel, oAS,ownd

   TRY
      oExcel := GetActiveObject( "Excel.Application" )
   CATCH
      TRY
         oExcel := CreateObject( "Excel.Application" )
      CATCH
         Alert( "ERROR! Excel not avialable. [" + Ole2TxtError()+ "]" )
         RETURN
      END
   END

   oExcel:WorkBooks:Add()   //Here I get error

   oAS := oExcel:ActiveSheet()

   oAS:Cells:Font:Name := "Arial"
   oAS:Cells:Font:Size := 12

   oAS:Cells( 3, 1 ):Value := "Text:"
   oAS:Cells( 3, 2 ):Value := "Here is some text"
   oAS:Cells( 4, 1 ):Value := "Numeric:"
   oAS:Cells( 4, 2 ):NumberFormat := "#.##0,00"
   oAS:Cells( 4, 2 ):Value := 1234.50
   oAS:Cells( 5, 1 ):Value := "Logical:"
   oAS:Cells( 5, 2 ):Value := .T.
   oAS:Cells( 6, 1 ):Value := "Date:"
   oAS:Cells( 6, 2 ):Value := DATE()

   oAS:Columns( 1 ):Font:Bold := .T.
   oAS:Columns( 2 ):HorizontalAlignment := -4152  // xlRight

   oAS:Columns( 1 ):AutoFit()
   oAS:Columns( 2 ):AutoFit()

   oAS:Cells( 1, 1 ):Value := "OLE from xHarbour"
   oAS:Cells( 1, 1 ):Font:Size := 16
   oAS:Range( "A1:B1" ):HorizontalAlignment := 7

   oAS:Cells( 1, 1 ):Select()

   oExcel:Visible := .T.

   MsgInfo( "ok" )

RETURN

//--------------------------------------------------------------------
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH
Posted: Sun Sep 04, 2011 01:45 AM
evitanso el uso de GetActivateObject se puede saltar el error

Code (fw): Select all Collapse
FUNCTION GetOleObject( cApp )
   LOCAL oObj

   TRY
      oObj  := TOleAuto():New( cApp )
   CATCH
      oObj := NIL
   END

RETURN oObj


seria interesante ver por que esta funciona falla en fwh.
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error de GetActiveObject solamente con FWH
Posted: Sun Sep 04, 2011 02:41 AM

We experienced this problem earlier with some versions of xharbour (org and mostly with com). It seems it is working well with recent versions of FWH and xharbour provided by FW.

May I know the versions of FWH and xHarbour you have used for this test?

Regards



G. N. Rao.

Hyderabad, India
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH
Posted: Sun Sep 04, 2011 07:18 PM

xharbour.org last svn, fwh 11.04
salu2

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error de GetActiveObject solamente con FWH
Posted: Mon Sep 05, 2011 02:00 AM
Mr Carlos

Please replace the functions GetOleObject(), WinWordObj(), ExcelObj() and SunCalcObj() in your version of \fwh\source\function\olefuncs.prg with the following code:
Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

function FWGetOleObject( cApp )

   local oObj

   TRY
      oObj  := GetActiveObject( cApp )
   CATCH
      TRY
         oObj  := CreateObject( cApp )
      CATCH
      END
   END

return oObj

//----------------------------------------------------------------------------//

function WinWordObj(); return FWGetOleObject( "Word.Application" )
function ExcelObj();   return FWGetOleObject( "Excel.Application" )
function SunCalcObj(); return FWGetOleObject( "com.sun.star.ServiceManager" )

//----------------------------------------------------------------------------//

After the change, please let us know if it works well.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH
Posted: Mon Sep 05, 2011 03:37 PM

nop, sorry, again the function GetActiveObject Hang the app. :-(
salu2
carlos vargas

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error de GetActiveObject solamente con FWH
Posted: Mon Sep 05, 2011 04:37 PM

Mr Carlos

Do you mind checking again? Please make sure the old obj file is removed from the library.

Let me explain the real issue. There is one GetOleObject() function in win32ole.prg of xharbour. Unfortunately olefuncs.prg of fwh also has another function with the same name resulting a clash and at times unending recursive calls.

I request you to try again and preferably remove olefuncs.obj from fivewin library.

Properly done, I am sure this modification should solve the problem

Regards



G. N. Rao.

Hyderabad, India
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH
Posted: Mon Sep 05, 2011 07:42 PM

ok, i follow your indications.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Error de GetActiveObject solamente con FWH (SOLVED)
Posted: Tue Sep 06, 2011 03:41 PM
I'ts a live..... :-)

rao, this patch work, I remove the olefunc.obj module from fivehx.lib


tlib fivehx *-olefuncs


and integrat in my project the code indicate:
Code (fw): Select all Collapse
/*-------------------------------------------------------------------------------------------------*/

FUNCTION FWGetOleObject( cApp )
   LOCAL oObj
   TRY
      oObj  := GetActiveObject( cApp )
   CATCH
      TRY
         oObj  := CreateObject( cApp )
      CATCH
      END
   END

RETURN oObj

/*-------------------------------------------------------------------------------------------------*/

FUNCTION WinWordObj(); RETURN FWGetOleObject( "Word.Application" )
FUNCTION ExcelObj();   RETURN FWGetOleObject( "Excel.Application" )
FUNCTION SunCalcObj(); RETURN FWGetOleObject( "com.sun.star.ServiceManager" )


thank you.
salu2
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Error de GetActiveObject solamente con FWH (SOLVED)
Posted: Tue Sep 06, 2011 04:34 PM

Thanks for confirmation.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion