FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Migrating to Harbour
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 04:52 PM
Richard,

Richard Chidiak wrote:Enrico

OleDefaultArg()

is a shortcut to:

VTWrapper( VT_ERROR, DISP_E_PARAMNOTFOUND )


Thank you. This is what I just tried (extract from xHarbour's win32ole.prg), but unfortunately it doesn't work:

Code (fw): Select all Collapse
FUNCTION MAIN()

    LOCAL oExcel := CREATEOBJECT( "Excel.Application" )

    LOCAL cXls := "e:\xharbour\test.xls"

    oExcel:WorkBooks:Open( cXls, , , OLEDEFAULTARG(), , , , OLEDEFAULTARG(), , , .T., , .T. )

    oExcel:Visible = .T.

    RETURN NIL


#define VT_ERROR 10
#define DISP_E_PARAMNOTFOUND 0x80020004


FUNCTION OLEDEFAULTARG()

    RETURN VTWRAPPER( VT_ERROR, DISP_E_PARAMNOTFOUND )


#include "Hbclass.ch"


CLASS VTWrapper

    DATA vt
    DATA Value

    METHOD New( vt, xVal ) CONSTRUCTOR

    ENDCLASS


METHOD New( vt, xVal ) CLASS VTWrapper

    ::vt := vt
    ::Value := xVal

    RETURN Self


I get:

Error WINOLE/1007 Impossibile trovare la proprieta Open per la classe Workbooks. (0x800A03EC): Microsoft Excel (DOS Error -2147352567)
Called from TOLEAUTO:OPEN(0)
Called from MAIN(7)


EMG
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 08:02 PM

Enrico

Please take a look at the excel workbooks property

http://msdn.microsoft.com/en-us/library ... =office.12).aspx

Oledefaultarg() is supposed to be the format parameter ?

Format Optional Variant If Microsoft Excel is opening a text file, this argument specifies the delimiter character. If this argument is omitted, the current delimiter is used. For more information on the values used by this parameter, see the Remarks section.

oExcel:WorkBooks:Open( cXls) will work ok

Hth

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 08:44 PM
Richard,

Richard Chidiak wrote:Enrico

Please take a look at the excel workbooks property

http://msdn.microsoft.com/en-us/library ... =office.12).aspx

Oledefaultarg() is supposed to be the format parameter ?

Format Optional Variant If Microsoft Excel is opening a text file, this argument specifies the delimiter character. If this argument is omitted, the current delimiter is used. For more information on the values used by this parameter, see the Remarks section.

oExcel:WorkBooks:Open( cXls) will work ok

Hth

Richard


My sample doesn't work without OleDefaultArg(). If I'm wrong, please show me how to successfully run it.

EMG
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 09:14 PM
Enrico

The code below works OK with Harbour if the file exists

I tried it with a file on my disk at it opened ok.

Note : I executed my test program as an administrator

Compiled with Harbour and Msvc

I sent you by email the exe , this way you can check your Harbour configuration also.

Richard

Code (fw): Select all Collapse
#INCLUDE "FIVEWIN.CH"

function Main()

    LOCAL oExcel := CREATEOBJECT( "Excel.Application" )

    LOCAL cXls  := CGETFILE("*.XLS", "Selectionnez le fichier")

    oExcel:WorkBooks:Open( cXls)

    oExcel:Visible = .T.


RETURN NIL
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 09:40 PM
Richard,

Richard Chidiak wrote:Enrico

The code below works OK with Harbour if the file exists

I tried it with a file on my disk at it opened ok.

Note : I executed my test program as an administrator

Compiled with Harbour and Msvc

I sent you by email the exe , this way you can check your Harbour configuration also.

Richard

Code (fw): Select all Collapse
#INCLUDE "FIVEWIN.CH"

function Main()

    LOCAL oExcel := CREATEOBJECT( "Excel.Application" )

    LOCAL cXls  := CGETFILE("*.XLS", "Selectionnez le fichier")

    oExcel:WorkBooks:Open( cXls)

    oExcel:Visible = .T.


RETURN NIL


This is not my sample. Please try my sample as it is. It works fine with xHarbour but not with Harbour (because Harbour doesn't have OleDefaultArg() function).

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Migrating to Harbour
Posted: Sat Oct 05, 2013 11:23 PM
Harbour doesn't have OleDefaultArg()

Yes.
This is needed very much for porting all our ole & ado apps and libs to Harbour, in complete shape.

We discussed this topic earlier in this thread. but left it before a solution could be found.
viewtopic.php?f=3&t=26577&p=146919&hilit=oledefaultarg#p146919
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Sun Oct 06, 2013 09:37 AM
NageswaraRao,

nageswaragunupudi wrote:
Harbour doesn't have OleDefaultArg()

Yes.
This is needed very much for porting all our ole & ado apps and libs to Harbour, in complete shape.

We discussed this topic earlier in this thread. but left it before a solution could be found.
viewtopic.php?f=3&t=26577&p=146919&hilit=oledefaultarg#p146919


Yes, I already reviewed it, thank you. :-)

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Mon Oct 07, 2013 08:13 PM

Friends, I'd like to know how do you migrate to Harbour if Harbour doesn't support OLE optional parameters.

Am I missing something?

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Migrating to Harbour
Posted: Mon Oct 07, 2013 09:15 PM

Not many use these features.
It is also possible to find workarounds in some cases.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Mon Oct 07, 2013 09:48 PM
NageswaraRao,

nageswaragunupudi wrote:Not many use these features.
It is also possible to find workarounds in some cases.


Is there a workaround to get my sample to work?

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Migrating to Harbour
Posted: Mon Oct 07, 2013 10:31 PM
Is this your code?
Code (fw): Select all Collapse
oExcel:WorkBooks:Open( cXls, , , OLEDEFAULTARG(), , , , OLEDEFAULTARG(), , , .T., , .T. )

You are using OleDefaultArg() for 4th and 8th parameters only and they are Format and Origin.
I refer to
http://msdn.microsoft.com/en-us/library ... 94819.aspx

Parameters:
Open(1.FileName, 2.UpdateLinks, 3.ReadOnly, 4.Format, 5.Password, 6.WriteResPassword, 7.IgnoreReadOnlyRecommended, 8.Origin, 9.Delimiter, 10.Editable, 11.Notify, 12.Converter, 13.AddToMru, 14.Local, 15.CorruptLoad)


Please try numbers 1 to 4 for the 4th parameter and xlWindows (we need to find the numeric value) for the 8th parameter.

I do not know why you want to specify .t. for parameters 11 and 12? Did I count the commas correctly? Or did you intend to specify .t. for params 10 and 11, which are Editable and Notify?

If you can accept the defaults for these last two parameters, it is enough to specify the first parameter alone.
Regards



G. N. Rao.

Hyderabad, India
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Migrating to Harbour
Posted: Tue Oct 08, 2013 01:45 AM
Rao,

I´ve got these in my excel.ch and a lot more. It´s 1555 lines long.

Code (fw): Select all Collapse
#define xlMacintosh 1
#define xlWindows 2
#define xlMSDOS 3
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Migrating to Harbour
Posted: Tue Oct 08, 2013 01:49 AM
ADutheil wrote:Rao,

I´ve got these in my excel.ch and a lot more. It´s 1555 lines long.

Code (fw): Select all Collapse
#define xlMacintosh 1
#define xlWindows 2
#define xlMSDOS 3

That's a great collection,
Can you send to me by mail?
nageswaragunupudi@gmail.com
It would be useful to all if we keep it in fwh\include folder
Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Migrating to Harbour
Posted: Tue Oct 08, 2013 08:34 AM
NageswaraRao,

nageswaragunupudi wrote:Is this your code?
Code (fw): Select all Collapse
oExcel:WorkBooks:Open( cXls, , , OLEDEFAULTARG(), , , , OLEDEFAULTARG(), , , .T., , .T. )

You are using OleDefaultArg() for 4th and 8th parameters only and they are Format and Origin.
I refer to
http://msdn.microsoft.com/en-us/library ... 94819.aspx

Parameters:
Open(1.FileName, 2.UpdateLinks, 3.ReadOnly, 4.Format, 5.Password, 6.WriteResPassword, 7.IgnoreReadOnlyRecommended, 8.Origin, 9.Delimiter, 10.Editable, 11.Notify, 12.Converter, 13.AddToMru, 14.Local, 15.CorruptLoad)


Please try numbers 1 to 4 for the 4th parameter and xlWindows (we need to find the numeric value) for the 8th parameter.

I do not know why you want to specify .t. for parameters 11 and 12? Did I count the commas correctly? Or did you intend to specify .t. for params 10 and 11, which are Editable and Notify?

If you can accept the defaults for these last two parameters, it is enough to specify the first parameter alone.


That's only a sample. I have a lot of code like that and I'm not willing to review any of those.

Anybody who can suggest the Harbour developers to implement ole optional parameter?

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Migrating to Harbour
Posted: Tue Oct 08, 2013 12:15 PM

Enrico,

Do you just need function OleDefaultArg() ?

regards, saludos

Antonio Linares
www.fivetechsoft.com