Corruption in OLE structures

362 views
Skip to first unread message

amminf x

unread,
Aug 1, 2017, 8:12:23 AM8/1/17
to Harbour Developers
Corruption in OLE structures

Hello everyone,

A few weeks ago I made the transition from xHarbour to Harbour, but some things do not work correctly:

In certain cases, and not always, with Excel, Outlook, etc. the data structure of OLE objects is "corrupted".

Win_OleCreateObject ("Excel.Application")
...
OHoja:Cells(1, 1):Font:Bold:= .t. // Sometimes it gives error


Sometimes causes this error:

1.Error
======================================================================
    Description Error: BASE / 1005 error No exported variable: BOLD

    Args:
      [1] = A {...} ARRAY [1] N. 0 [2] N. 6510284
      [2] = L .T. LOGICAL



Note Args: [1] should to be a font excel object but it's a array with two items.


Any ideas ?

Using Harbor 3.2


Diego Fazio

unread,
Aug 8, 2017, 6:51:51 AM8/8/17
to Harbour Developers
Replace Win_OleCreateObject with tOleAuto()

Obj := tOleAuto():New( "Excel.Application" )

Diego.

Marek Horodyski

unread,
Aug 8, 2017, 8:40:49 AM8/8/17
to harbou...@googlegroups.com
Od: "Diego Fazio" <diego...@gmail.com>
Do: "Harbour Developers" <harbou...@googlegroups.com>;
Wysłane: 12:51 Wtorek 2017-08-08
Temat: [harbour] Re: Corruption in OLE structuresReplace Win_OleCreateObject with tOleAuto()
Obj := tOleAuto():New( "Excel.Application" )
Diego.

El martes, 1 de agosto de 2017, 9:12:23 (UTC-3), amminf x escribió:Corruption in OLE structures
Hello everyone,
A few weeks ago I made the transition from xHarbour to Harbour, but some things do not work correctly:
In certain cases, and not always, with Excel, Outlook, etc. the data structure of OLE objects is "corrupted".
Win_OleCreateObject ("Excel.Application")...OHoja:Cells(1, 1):Font:Bold:= .t. // Sometimes it gives error

Sometimes causes this error:
1.Error======================================================================    Description Error: BASE / 1005 error No exported variable: BOLD
    Args:      [1] = A {...} ARRAY [1] N. 0 [2] N. 6510284      [2] = L .T. LOGICAL
*----------

Hi,
and how when you giv space after "Bold"?

Regards,
Marek Horodyski

amminf x

unread,
Mar 14, 2018, 5:28:03 PM3/14/18
to Harbour Developers
Hi Diego,

With TOleAuto, too error. My program message error:

ERROR: ¡ Se produjo un error  !                                               
------------------------------------------------------------------------------------------------------------------------
cSaveAsFileName.......................: C/Len: 62 "C:\Users\Juani\AppData\Local\Temp\33\Extractos de Venta.Xlsx"
File(cSaveAsFileName).................: L/.F.
IsDirectory(PathFile(cSaveAsFileName)): L/.T.
oBook.................................: A/Array[   2] Array[1]=U/NIL
oError................................: O/Class: ERROR
oError:SubSystem()....................: C/Len: 4 "BASE"
oError:Description....................: C/Len: 17 "Message not found"
oError:Operation......................: C/Len: 12 "ARRAY:SAVEAS"
oError:SubCode........................: N/1004
oError:FileName.......................: C/Len: 0 ""
DosError()............................: N/0
FError()..............................: N/0
Ole2TxtError()........................: C/Len: 0 ""
GetEnv("TMP").........................: C/Len: 36 "C:\Users\Juani\AppData\Local\Temp\33"
GetEnv("TEMP")........................: C/Len: 36 "C:\Users\Juani\AppData\Local\Temp\33"
oExcel................................: O/Class: TOLEAUTO
lFiAccess(cSaveAsFileName)............: L/.F.
DosError()............................: N/0
FError()..............................: N/2


any hint, pls ?

Diego Fazio

unread,
Mar 15, 2018, 4:55:53 AM3/15/18
to Harbour Developers
Try this....win_oleCreateObject shold work ok with Excel.Application in harbour v3.2

STATIC PROCEDURE Exm_MSExcel()

   LOCAL oExcel, oWorkBook, oWorkSheet, oAS
   LOCAL nI, nCount

   IF ( oExcel := win_oleCreateObject( "Excel.Application" ) ) != NIL

      oWorkBook := oExcel:WorkBooks:Add()

      // Enumerator test
      FOR EACH oWorkSheet IN oWorkBook:WorkSheets
         ? oWorkSheet:Name
      NEXT

      // oWorkBook:WorkSheets is a collection
      nCount := oWorkBook:WorkSheets:Count()

      // Elements of collection can be accessed using :Item() method
      FOR nI := 1 TO nCount
         ? oWorkBook:WorkSheets:Item( nI ):Name
      NEXT

      // OLE also allows to access collection elements by passing
      // indices to :Worksheets property
      FOR nI := 1 TO nCount
         ? oWorkBook:WorkSheets( nI ):Name
      NEXT

      oAS := oExcel:ActiveSheet()

      // Set font for all cells
      oAS:Cells:Font:Name := "Arial"
      oAS:Cells:Font:Size := 12

      oAS:Cells( 1, 1 ):Value := "OLE from Harbour"
      oAS:Cells( 1, 1 ):Font:Size := 16

      // oAS:Cells( 1, 1 ) is object, but oAS:Cells( 1, 1 ):Value has value of the cell
      ? "Object valtype:", ValType( oAS:Cells( 1, 1 ) ), "Value:", oAS:Cells( 1, 1 ):Value

      oAS:Cells( 3, 1 ):Value := "String:"
      oAS:Cells( 3, 2 ):Value := "Hello, World!"

      oAS:Cells( 4, 1 ):Value := "Numeric:"
      oAS:Cells( 4, 2 ):Value := 1234.56
      oAS:Cells( 4, 3 ):Value := oAS:Cells( 4, 2 ):Value
      oAS:Cells( 4, 4 ):Value := oAS:Cells( 4, 2 ):Value
      oAS:Cells( 4, 3 ):Value *= 2
      oAS:Cells( 4, 2 ):Value++

      oAS:Cells( 5, 1 ):Value := "Logical:"
      oAS:Cells( 5, 2 ):Value := .T.

      oAS:Cells( 6, 1 ):Value := "Date:"
      oAS:Cells( 6, 2 ):Value := Date()

      oAS:Cells( 7, 1 ):Value := "Timestamp:"
      oAS:Cells( 7, 2 ):Value := hb_DateTime()

      // Some formatting
      oAS:Columns( 1 ):Font:Bold := .T.
      oAS:Columns( 2 ):HorizontalAlignment := - 4152  // xlRight

      oAS:Columns( 1 ):AutoFit()
      oAS:Columns( 2 ):AutoFit()
      oAS:Columns( 3 ):AutoFit()
      oAS:Columns( 4 ):AutoFit()

      oAS:Cells( 3, 2 ):Font:ColorIndex := 3  // red

      oAS:Range( "A1:B1" ):HorizontalAlignment := 7
      oAS:Range( "A3:A7" ):Select()

      oExcel:Visible := .T.

      oExcel:Quit()
   ELSE
      ? "Error: MS Excel not available. [" + win_oleErrorText() + "]"
   ENDIF

   RETURN

Diego

amminf x

unread,
Mar 15, 2018, 6:06:19 AM3/15/18
to Harbour Developers
Diego,

"_In certain cases, and not always_, with Excel, Outlook, etc. the data structure of OLE objects is "corrupted". "


Thks.

Diego Fazio

unread,
Mar 15, 2018, 8:18:41 AM3/15/18
to Harbour Developers
Try this at the end of the code....

RELEASE oExcel

Some objects do not work well without RELEASE command at the end.
I have also found some cases that I did not define the variable at the beginning with LOCAL and I had problems.
The CreateObject() function is similar to win_oleCreateObject. You can try to replace it and see what happens.


Diego.
Reply all
Reply to author
Forward
0 new messages