FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Excel OLE RTE when compiled with Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 06:34 AM
Hi guys,
I'm trying to migrate a module that I have to FWH+Harbour instead of xHb
However this line of code generates RTE under Harbour but ran fine all this while under xHb
Code (fw): Select all Collapse
  ::oSheet := ::oExcel:ActiveSheet
 ::oSheet:set("Name", "A & T ELEC")


The error was

FiveWin version: FWH 19.05
C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
Windows version: 10.0, Build 18363

Time from start: 0 hours 0 mins 18 secs
Error occurred at: 23/08/2022, 14:28:59
Error description: (DOS Error -2147352572) WINOLE/1007 Argument error: SET
Args:
[ 1] = C Name
[ 2] = C A & T ELEC

Stack Calls
===========
Called from: => TOLEAUTO:SET( 0 )
Called from: .\statprnx.PRG => STATPRNXLS:HEADER( 136 )


Anyone has any idea of how to solve this?
TIA
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 06:45 AM

Dear Hua,

Please try it again removing the "&" to see if that makes a difference:

::oSheet:set("Name", "A T ELEC")

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 07:15 AM

Thanks for the prompt reply Antonio.

Removing '&' didn't help. The same error occured

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 07:50 AM
Try with
Code (fw): Select all Collapse
::oSheet := ::oExcel:ActiveSheet
 ::oSheet:name := "A & T ELEC"
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 08:28 AM

Thanks Cristobal! That was it :)

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Wed Aug 24, 2022 02:02 AM
Another error I found after compiling with Harbour. Instead of a logical value, lRetVal ends up with an array {0, 5813120}
Code (fw): Select all Collapse
      lRetVal := StatPrnXls():activate(cTitle, cFrom, cTo, dCOD, lPrnZero)
      return lRetVal


I don't even know where to begin to find out what went wrong. The last line in StatPrnXls():activate() simply returns .t. and yet lRetVal ends up with an array

Any tips? Suggestions?
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Excel OLE RTE when compiled with Harbour
Posted: Wed Aug 24, 2022 06:37 AM

You could try this:

instead of
return lRetVal

use
return lRetVal[ 2 ] != 0

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Thu Aug 25, 2022 01:56 AM

Whether StatPrnXls():activate() returns .t. or .f. lRetVal always ends up with {0, 5813120}

I can't wrap my mind on what's happening. Called class returns a logical value yet lRetVal ends up with an array

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Mon Aug 29, 2022 10:05 AM

May I know what is this "StatPrnXls()" ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Mon Aug 29, 2022 10:05 AM

May I know what is this "StatPrnXls()" ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 02:35 AM

Hi Rao,
StatPrnXls() is a class in my program that generates a report directly in Excel using OLE.
The last line in StatPrnCls():activate() is return .t. hence my bewilderment when lRetVal contains an array

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 03:03 AM

Nice.
Do you mind sharing your class with me?

Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 03:28 AM

It's just a crude report written in class form as I try to avoid using public,private variable as much as possible :)
Irregardless, I've emailed it to you.
Thank you

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 07:52 AM

Thank you

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 09:56 AM
I remember having experienced the same problem, when I was writing the METHOD ToExcel() of XBrowse.
Please see my notes towards the end of ToExcel() method in XBrowse.
Code (fw): Select all Collapse
 
#ifndef __XHARBOUR__
   else
      //
      SysRefresh()
      //
      // This requires explanation.
      // With xHarbour there is no problem. Problem is with Harbour only
      // return value of this function is oSheet which is an Object. xHarbour returns as object
      // If SysRefresh() is called here, Harbour returns oSheet as an object
      // if not it returns an Array of two numeric elements.
      // I am unable to understand this phenomenon.
      // Till we understand what is happening, keep SysRefresh() here for
      // Harbour build.
      // 2015-06-02
#endif
   endif

return oSheet


So, in your case also I guess xHarbour returns .T. but Harbour returns an array of two numeric elements.

Please insert
Code (fw): Select all Collapse
SysRefresh()

just beore
Code (fw): Select all Collapse
return .t.


I expect this will solve your problem.
Please test and let us know the result.
Regards



G. N. Rao.

Hyderabad, India