Dbf To Excel ( Ole2TxtError() )

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Mario Mansilla
Posts: 271
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Dbf To Excel ( Ole2TxtError() )

Post by Mario Mansilla »

Hola :
alguien ha experimentado problemas con la funcion Ole2TxtError() con la nueva version de Harbour .
Tengo una aplicacion donde evaluo la instalacion de Excel y aunque este instalado la funcion no devuelve "S_OK" como antes .
Probe con Try Cath como alternativa pero en Harbour da error .

Hi:
someone has experienced problems with Ole2TxtError() function with the new version of Harbour.
I have an application where Excel will assess the installation and installed but this function does not return "S_OK" as before.
Try Probe with Cath as an alternative but fails in Harbour

Hmg 3.0
//////
oExcel := CreateObject("Excel.Application")

If Ole2TxtError() != "S_OK" <-- Error
MsgStop("Excel no esta disponible" )
Return nil
Endif
////////

Saludos
Mario Mansilla
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Dbf To Excel ( Ole2TxtError() )

Post by mol »

Maybe try to test returned value:

xAnswer := Ole2TxtError()
MsgBox("The type of answer is: " + valtype(xAnswer))

Maybe little sample?

(I'm using export to excel in my project, but I'm using BEGIN SEQUENCE... RECOVER
to catch errors)
Mario Mansilla
Posts: 271
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Re: Dbf To Excel ( Ole2TxtError() )

Post by Mario Mansilla »

Hola Mol
He probado lo que me propusiste y me devuelve un caracter nulo (nil) , ascii (cero) .

Tienes un ejemplo de uso de BEGIN SEQUENCE .. RECOVER para capturar errores .

Saludos .
Mario Mansilla

Hello Mol
I tried what I set out and returns me a null character (nil), ascii (zero).

You have an example of use of BEGIN SEQUENCE .. RECOVER to catch errors.

Greetings.
Mario Mansilla
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Dbf To Excel ( Ole2TxtError() )

Post by mol »

Code: Select all

	
        XLSfile := "sample.xls"
	OldErrorDriver  := ErrorBlock({|e| break(e)})
	BEGIN SEQUENCE
		
		oExcel := CreateObject( "Excel.Application")
		oExcel:Workbooks:Open(XLSfile, 2, .f., 1, "", "", .f.)

		if oExcel:ActiveWorkBook:ReadOnly
			MsgInfo("XLS file cannot be open in WRITE mode!")
			lSheetOK := .f.
			oExcel:Quit()
			// remove excel from memory
			oExcel := NIL
		else
                        // I need to turn off autocalculation in Excel to speed writing to sheet
			xlCalcStatus := oExcel:Calculation
			oExcel:Calculation := xlManual
		endif
		
	RECOVER 
		MsgInfo("error while opening " + XLSfile)
		lSheetOK := .f.
	END
It's really working!
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Dbf To Excel ( Ole2TxtError() )

Post by mol »

Remember to restore error handle after

Code: Select all

   ErrorBlock(OldErrorDriver)
Mario Mansilla
Posts: 271
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Re: Dbf To Excel ( Ole2TxtError() )

Post by Mario Mansilla »

Gracias Mol
Thanks Mol

Greetings.
Mario Mansilla
Post Reply