FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with connection to Word using OLE
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 10:45 AM
Hello,

If I build my application with xHarbour, I don't have any problems. The connection with Word by using OLE is working just fine.

But if I build my application with Harbour and I use this code:
wWord:Activate()
I got sometimes this error telling me that there is no exported methos Activate() which is a Word-function. I looks that my application is not recognizing this function immediately:
Application
===========
Path and name: C:\JUDA\JUDA_2.EXE (32 bits)
Size: ********* bytes
Compiler version: Harbour 3.2.0dev (r2403071241)
FiveWin version: FWH 25.04
C compiler version: Borland/Embarcadero C++ 7.7 (32-bit)
Windows 11 64 Bits, version: 6.2, Build 9200

Time from start: 20 sec
Error occurred at: 08/06/2025, 12:32:20
Error description: Error BASE/1004 No exported method: ACTIVATE
Args:
[ 1] = A {,5658318} length: 2

Stack Calls
===========
Called from: .\BEHAGEN1.PRG => ACTIVATE( 0 )
Called from: .\JUDA.PRG => WORDACTIV( 4223 )
Called from: .\JUDA.PRG => WORDOPEN( 3992 )
Called from: .\DOCWP1.PRG => WPDOC( 1158 )
Called from: .\FGEGTL2.PRG => (b)VULMENU1( 3340 )
Called from: .\source\classes\menu.prg => TMENU:COMMAND( 1582 )
Called from: .\source\classes\window.prg => TWINDOW:COMMAND( 1188 )
Called from: .\source\classes\window.prg => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\window.prg => _FWH( 3729 )
Called from: .\source\classes\window.prg => WINRUN( 0 )
Called from: .\source\classes\window.prg => TWINDOW:ACTIVATE( 1147 )
Called from: .\JUDA.PRG => MAIN( 1055 )

System
======
CPU type: 13th Gen Intel(R) Core(TM) i7-13700H 2918 Mhz
Hardware memory: 16065 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Windows total applications running: 1
1 LOGI_RAWINPUT_WND,

Variables in use
================
Procedure Type Value
==========================
ACTIVATE
Param 1: O Class: ERROR
WORDACTIV
Local 1: U
Local 2: U
WORDOPEN
Param 1: N 1
WPDOC
Param 1: N 1
Param 2: C "C:\JUDA\DOCTEMP\BRIE105.docx"
Local 1: L .T.
Local 2: L .F.
Local 3: L .T.
(b)VULMENU1
Param 1: N 83
Param 2: N 0
Local 1: N 0
Local 2: U
Local 3: U
Local 4: C ""
Local 5: L .T.
Local 6: L .T.
Local 7: L .F.
Local 8: U
Local 9: L .F.
Local 10: L .T.
Local 11: L .T.
Local 12: L .F.
Local 13: C ""
Local 14: U
Local 15: N 0
Local 16: L .T.
Local 17: A Len: 0
Local 18: L .F.
Local 19: L .F.
Local 20: C "O"
Local 21: C "SOFTWARE\JUDA\DATA"
Local 22: A Len: 4
Local 23: A Len: 0
Local 24: N 0
Local 25: N 0
Local 26: C ""
Local 27: A Len: 0
Local 28: A Len: 0
Local 29: L .T.
Local 30: L .F.
Local 31: L .T.
Local 32: L .T.
Local 33: C " "
Local 34: C " "
Local 35: C "DOCUMENT IN AANMAAK : Brief cli nt - kopie meedelen (Nr. document : 361.235)"
Local 36: C "DOCUMENT IN AANMAAK : "
Local 37: C ""
Local 38: A Len: 3
Local 39: A Len: 1
Local 40: C "Doss. 99/0266 - KBC BANK-'S JONGERS /c ETABLISSEMENTEN GEORGES-GEBEDI HOLDING-CHAMPAGNE SERVICE-CHAMPAGNE BETON /i DE CLERCQ-SCHOOFS"
Local 41: C "99/0266-0 "
Local 42: L .F.
Local 43: L .F.
Local 44: L .F.
Local 45: L .F.
Local 46: L .T.
Local 47: A Len: 5
Local 48: A Len: 0
Local 49: C "99/0266-0 "
Local 50: C "99 "
Local 51: C "0266 "
Local 52: C "0"
Local 53: N 0
TMENU:COMMAND
Param 1: O Class: TMENUITEM
TWINDOW:COMMAND
Param 1: N 20861
Local 1: O Class: TMENUITEM
TWINDOW:HANDLEEVENT
Param 1: N 20861
Param 2: N 0
Local 1: N 0
Local 2: N 20861
Local 3: N 0
Local 4: U
_FWH
Param 1: N 273
Param 2: N 20861
Param 3: N 0
WINRUN
Param 1: N 0
Param 2: N 273
Param 3: N 20861
Param 4: N 0
Param 5: N 2
Local 1: O Class: TWINDOW
TWINDOW:ACTIVATE
Param 1: N 6294372
MAIN
Param 1: C "NORMAL"
Param 2: U
Param 3: U
Param 4: U
Param 5: U
Param 6: U
Param 7: U
Param 8: B {|| ... }
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: B {|| ... }
Param 18: U
Param 19: U
Param 20: L .F.
Param 21: U
Local 1: O Class: TWINDOW
Local 2: U
Local 3: U
It looks to me there must be a Harbour problem in using OLE.

I tried this:
TRY
   wWord:Activate()
CATCH
   TRY
      wWorrd:Activate()
   CATCH
      TRY
         wWord:Activate()
      CATCH
      END
   END
END
I tried this code. In most cases (not always) it works fine. But triple all this pieces of code is impossible. Does anyone know what the problem is and send me a solution?

Thank you very much in advance for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 02:20 PM
Dear Michel,

I wonder why there is an array here instead of an object:

Error description: Error BASE/1004 No exported method: ACTIVATE
Args:
[ 1] = A {,5658318} length: 2

How do you create the word object ? Please share the code, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 06:02 PM

Eones tendrá de tiempo la primera vez que yo reporté el error sin que nadie pudiera contestar a qué se debia.

Varias veces he ayudado algunos compañeros con los posibles workaround que se puede encontrar en este foro.

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 06:54 PM

Mr. paquitohm,

Is it possible to reply in English since I don't speak any Spanisch.

Thank you very much.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 07:17 PM

Of course, here's the translation:

Eons of time passed since I first reported the bug and no one could answer what caused it.

I've helped colleagues several times with possible workarounds, which can be found in this forum.

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 07:37 PM

Thanks a lot.

I tried to search for your items concerning this problem.

Unfortunately I wasn't able to find any of them.

Can you tell me where I can find them?

Thank you so much.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 07:58 PM

Dear Michel,

How do you create the word object ? Please share the code, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 09:49 PM
Antonio,

This is the way I always create my Word-object.
cWord := WinWordObj()
cWdoc := cWord:Documents:Open(cFile)
cWdoc:Activate()
....
cWdoc:Save()

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 10:05 PM

Dear Michel,

Could you please modify your code this way ?

cWdoc := cWord:Documents:Open(cFile)

if ValType( cWdoc ) != "O"

MsgAlert( "could not open the file " + cFile, please retry" )

return nil

endif

We need to find why sometimes it fails to open the file. Maybe it does not exist ? Maybe it has a wrong name ?

thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Sun Jun 08, 2025 11:14 PM

Antonio,

Opening the file is not the problem.

The Word document is opened.

It appears on my screen.

The error occurs when I want to activate it.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: Problem with connection to Word using OLE
Posted: Mon Jun 09, 2025 11:10 AM

Hello,

He is my code with harbour :

TRY

  owrd   := GetActiveObject( "word.application" )

CATCH

  TRY

     owrd   := CreateObject( "word.application" )

  CATCH

     MsgAlert( "Word  not installed" )

     return

  END

END

*

oWrd:visible:=.T.

oWrd:WindowState := 1 && normal 1 minimize 2 maximum wdWindowStateNormal

*

wdoc:="c:\temp\test.docx"

oDoc:=oWrd:Documents:Open(wdoc)

Philippe from Belgium

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problem with connection to Word using OLE
Posted: Mon Jun 09, 2025 12:31 PM

What is Activate() method for? I never used it.

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Mon Jun 09, 2025 01:32 PM

Activate() is used to select the active document in case you have more than one Word document opened.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problem with connection to Word using OLE
Posted: Mon Jun 09, 2025 01:52 PM

You don't need to activate one, you only need to use two different variables (ie. oDoc1, oDoc2).

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Problem with connection to Word using OLE
Posted: Mon Jun 09, 2025 01:57 PM

I know that. But if I want to do something in a document, I need to chose one of the documents. To d that, I need oDoc1:Activate() .OR. oDoc2:Activate()/

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773