Page 3 of 4

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 4:52 pm
by Enrico Maria Giordano
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: Select all  Expand view
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

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 8:02 pm
by Richard Chidiak
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

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 8:44 pm
by Enrico Maria Giordano
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

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 9:14 pm
by Richard Chidiak
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: Select all  Expand view

#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
 

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 9:40 pm
by Enrico Maria Giordano
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: Select all  Expand view

#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

Re: Migrating to Harbour

PostPosted: Sat Oct 05, 2013 11:23 pm
by nageswaragunupudi
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

Re: Migrating to Harbour

PostPosted: Sun Oct 06, 2013 9:37 am
by Enrico Maria Giordano
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

Re: Migrating to Harbour

PostPosted: Mon Oct 07, 2013 8:13 pm
by Enrico Maria Giordano
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

Re: Migrating to Harbour

PostPosted: Mon Oct 07, 2013 9:15 pm
by nageswaragunupudi
Not many use these features.
It is also possible to find workarounds in some cases.

Re: Migrating to Harbour

PostPosted: Mon Oct 07, 2013 9:48 pm
by Enrico Maria Giordano
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

Re: Migrating to Harbour

PostPosted: Mon Oct 07, 2013 10:31 pm
by nageswaragunupudi
Is this your code?
Code: Select all  Expand view
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.

Re: Migrating to Harbour

PostPosted: Tue Oct 08, 2013 1:45 am
by ADutheil
Rao,

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

Code: Select all  Expand view

#define xlMacintosh 1
#define xlWindows 2
#define xlMSDOS 3
 

Re: Migrating to Harbour

PostPosted: Tue Oct 08, 2013 1:49 am
by nageswaragunupudi
ADutheil wrote:Rao,

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

Code: Select all  Expand view

#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

Re: Migrating to Harbour

PostPosted: Tue Oct 08, 2013 8:34 am
by Enrico Maria Giordano
NageswaraRao,

nageswaragunupudi wrote:Is this your code?
Code: Select all  Expand view
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

Re: Migrating to Harbour

PostPosted: Tue Oct 08, 2013 12:15 pm
by Antonio Linares
Enrico,

Do you just need function OleDefaultArg() ?