Page 1 of 2
Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 6:34 am
by hua
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: Select all | Expand
::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
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 6:45 am
by Antonio Linares
Dear Hua,
Please try it again removing the "&" to see if that makes a difference:
::oSheet:set("Name", "A T ELEC")
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 7:15 am
by hua
Thanks for the prompt reply Antonio.
Removing '&' didn't help. The same error occured
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 7:50 am
by cnavarro
Try with
Code: Select all | Expand
::oSheet := ::oExcel:ActiveSheet
::oSheet:name := "A & T ELEC"
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 23, 2022 8:28 am
by hua
Thanks Cristobal! That was it

Re: Excel OLE RTE when compiled with Harbour
Posted: Wed Aug 24, 2022 2:02 am
by hua
Another error I found after compiling with Harbour. Instead of a logical value, lRetVal ends up with an array {0, 5813120}
Code: Select all | Expand
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?
Re: Excel OLE RTE when compiled with Harbour
Posted: Wed Aug 24, 2022 6:37 am
by Antonio Linares
You could try this:
instead of
return lRetVal
use
return lRetVal[ 2 ] != 0
Re: Excel OLE RTE when compiled with Harbour
Posted: Thu Aug 25, 2022 1:56 am
by hua
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
Re: Excel OLE RTE when compiled with Harbour
Posted: Mon Aug 29, 2022 10:05 am
by nageswaragunupudi
May I know what is this "StatPrnXls()" ?
Re: Excel OLE RTE when compiled with Harbour
Posted: Mon Aug 29, 2022 10:05 am
by nageswaragunupudi
May I know what is this "StatPrnXls()" ?
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 2:35 am
by hua
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
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 3:03 am
by nageswaragunupudi
Nice.
Do you mind sharing your class with me?
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 3:28 am
by hua
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
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 7:52 am
by nageswaragunupudi
Thank you
Re: Excel OLE RTE when compiled with Harbour
Posted: Tue Aug 30, 2022 9:56 am
by nageswaragunupudi
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: Select all | Expand
#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
just beore
I expect this will solve your problem.
Please test and let us know the result.