FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with closing word-documents using OLE
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with closing word-documents using OLE
Posted: Wed Nov 26, 2008 06:14 PM
Hello,

My application use OLE to make a connection to Word.

Consider this situation :

I have opened a Word-document in my FWH-application. Manually, I open a second Word-document, apart from my application.

Then I want to close my document opened by my application. To do this, I use this syntax :
wOle:Documents:Close()

But what happens ? Not only my document, opened by my application through OLE is closed. My manually opened document is closed too.

I want to close only the document, opened by my application through OLE. But how do I do that ?

I hope to have been understandable to you all.

Thanks a lot 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: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problem with closing word-documents using OLE
Posted: Wed Nov 26, 2008 10:00 PM
oDoc:Close( 0 )


EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with closing word-documents using OLE
Posted: Wed Nov 26, 2008 11:30 PM
Enrico,

Thanks for your answer.

But where do I define oDoc ?

I open my document by using :
wOle:Documents:Open(cFileName)

Maybe another question. Where can I get some more information about the correct syntax concerning OLE ? I know that you referred to VBA-tutorials in the past. But how do I translate the syntax of VBA to FWH ?

Thanks.

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
Problem with closing word-documents using OLE
Posted: Thu Nov 27, 2008 08:49 AM
driessen wrote:Enrico,

Thanks for your answer.

But where do I define oDoc ?


This is a sample:

FUNCTION MAIN()

    LOCAL oWord := CREATEOBJECT( "Word.Application" )

    LOCAL oDoc := oWord:Documents:Open( "E:\XHARBOUR\TEST.DOC" )

    oDoc:PrintOut( .F. )

    oDoc:Close( 0 )

    oWord:Quit()

    RETURN NIL


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Problem with closing word-documents using OLE
Posted: Thu Nov 27, 2008 08:52 AM
driessen wrote:Where can I get some more information about the correct syntax concerning OLE ?


There is nothing like "OLE syntax". You have to refer to the syntax of a specific OLE server, in your case Word.

driessen wrote:I know that you referred to VBA-tutorials in the past. But how do I translate the syntax of VBA to FWH ?


That's your work. :-) Anyway, they are very similar.

EMG
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with closing word-documents using OLE
Posted: Thu Nov 27, 2008 01:30 PM
Enrico,

oDoc:Close(0) seems to working fine.

What does the "0" mean in this instruction ?

I have another question.

After my document is closed, I want to make the Word-session invisible. I do this by using this code :
wOle:Visible := .F.

But if I have a manually opened document, this document disappears too.
How can the Word-session in which oDoc was opened, made invisible, leaving the Word-session with the manually opened document as it was ?

Thanks a lot in advance.

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
Problem with closing word-documents using OLE
Posted: Thu Nov 27, 2008 02:32 PM
driessen wrote:What does the "0" mean in this instruction ?


wdDoNotSaveChanges

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Problem with closing word-documents using OLE
Posted: Thu Nov 27, 2008 02:39 PM
driessen wrote:After my document is closed, I want to make the Word-session invisible. I do this by using this code :
wOle:Visible := .F.

But if I have a manually opened document, this document disappears too.
How can the Word-session in which oDoc was opened, made invisible, leaving the Word-session with the manually opened document as it was ?


I don't know, sorry.

EMG

Continue the discussion