ActiveX or OLE for WINWORD?

Post Reply
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

ActiveX or OLE for WINWORD?

Post by Otto »

I would like to start using WINWORD from FWH.
Do I have to use ActiveX or OLE?

Which libs do I have to include to use ActiveX from Harbour?


Thanks in advance
Otto
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: ActiveX or OLE for WINWORD?

Post by Enrico Maria Giordano »

Otto wrote:I would like to start using WINWORD from FWH.
Do I have to use ActiveX or OLE?
OLE if you just want to use Word as an external application. ActiveX if you want to use Word as an embedded application.
Otto wrote:Which libs do I have to include to use ActiveX from Harbour?
Harbour? hbole.lib, I think.

EMG
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Ole for Winword

Post by ukoenig »

Hello Otto,

For Winword, You can use AutoOle, same like in Excel.
I look in my archiv, to find some samples for you.

Regards

Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Hello Enrico,

Thank you for your help. Now I tried the word.prg-sample from the FIVEWIN examples.
I linked HBOLE.LIB (my lib is from 2004).

But I get a Harbour exception error.

Maybe you can give me some more help.

Regards e Buona pasqua,
Otto

Code: Select all

// Using Microsoft Office Word ActiveX

#include "FiveWin.ch"

function Main()
    local oWnd, oActiveX, cString

    DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Support"

    if IsActivex( "Word.Application.8" )
        cString := "Word.Application.8"
    endif
    if IsActivex( "Word.Application.9" )
        cString := "Word.Application.9"
    endif
    if IsActivex( "Word.Application.10" )
        cString := "Word.Application.10"
    endif
    if IsActivex( "Word.Application.11" )
        cString := "Word.Application.11"
    endif
    if IsActivex( "Word.Application.12" )
        cString := "Word.Application.12"
    endif

    oActiveX = TActiveX():New( oWnd, cString )

    oWnd:oClient = oActiveX                     // To fill the entire window surface

    ACTIVATE WINDOW oWnd

return nil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

You have to link hbwin32.lib
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Antonio, thank you.
I have echo %hdir%\lib\hbwin32.lib + >> b32.bc
in my linkscript.
But the error is still there. Could you compile the file
and send me your exe for testing, please.
Maybe there is something wrong on my PC.
Thanks in advance
Otto
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

I guess you are testing Word 2007. It also GPFs here. It seems there is a conflict between Class TActiveX and Word 2007.

We are googling for some info about it, and we have found that VB users are also having troubles:

http://www.google.es/search?hl=es&q=%22 ... 2007&meta=

http://www.google.com/search?hl=en&q=%2 ... tion.12%22
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

I am not able to use Excel 2007 also with activex. My earlier code is not working with 2007.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Nageswararao,

What ProgID string are you using for Excel 2007 ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Post by xProgrammer »

Hi Otto

Not sure what you want to do with Word so hard to make recommendations. If you tell us a bit more about what you want to achieve we can possibly help more.

I used Word from FiveWin code a number of times and it worked well. (I got off the Microsoft gravy train so I don't have 2007 so can't test that.)

Amongst the things I did:

FiveWin program to control word to open and convert many thousands of Word documents to straight text format so that I could do data mining on them.

FiveWin program to draft up medical reports for editing etc by doctors

FiveWin code producing reports as Word documents.

Speed was very pleasing (I didn't expect that).

For producing reports I wrote a basic class (MLETTER) to handle all the Word details in one place.

Basic code looks like:

Code: Select all

::oWord := CREATEOBJECT( "Word.Application" )
::oWord:Visible := .T.     // if you want to see it
::oDocument := oWord:Documents:Add()
::oDocument:SaveAs( sFileName, WdFormatDocument )  // WdFormatDocument is a defined constant
::oRange := ::oDocument:Range( 0, 0 )
::oRange:InsertBefore( sDateAsText )
::oRange:ParagraphFormat:Alignment := WdAlignParagraphRight   //WdAlignParagraphRight is a defined constant
::oRange:InsertParagraphAfter()
::iEnd := ::oRange:End
::oRange := ::oDocument:Range( ::iEnd, ::iEnd )
::oRange:InsertAfter( sGreeting )
::oRange:ParagraphFormat:Alignment := WdAlignParagraphLeft   //WdAlignParagraphLeft is a defined constant
::oRange:InsertParagraphAfter()
::iEnd := ::oRange:End
AS you can see the first insert is a little different (InsertAfter seems to fail with a document with no contents, but from then on its plain sailing. As you go you can add refinements, eg

Code: Select all

::oRange:Bold := .T.
::oRange:FontName := "Arial"
By the way if you just want to produce documents that Word can subsequently handle why not consider switching to the XML based standard (which Word now grudgingly supports I believe) in which case no special programming is required. I am now doing that, although I do want to write some code to control OpenOffice from a FiveLinux application (on a LInux platform)

I hope that may be of some help.

I can't guarantee that the code is 100% correct as I had to retype it and change it a bit as I went so it wasn't confused by my particular needs.

Regards
Doug
(xProgrammer)
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Doug, thank you for your answer.
I only want to run the demo sample with ActiveX.

Antonio, I tried the Exe now on a WINDOWS XP/WORD2003 PC and
I get the same error:

Image

Would you be so kind to compile the above code so I can test with
your exe.

Regards,
Otto
Post Reply