Problem with closing word-documents using OLE

Problem with closing word-documents using OLE

Postby driessen » Wed Nov 26, 2008 6: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 :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Postby driessen » Wed Nov 26, 2008 11:30 pm

Enrico,

Thanks for your answer.

But where do I define oDoc ?

I open my document by using :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Enrico Maria Giordano » Thu Nov 27, 2008 8:49 am

driessen wrote:Enrico,

Thanks for your answer.

But where do I define oDoc ?


This is a sample:

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Thu Nov 27, 2008 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby driessen » Thu Nov 27, 2008 1: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 :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Enrico Maria Giordano » Thu Nov 27, 2008 2:32 pm

driessen wrote:What does the "0" mean in this instruction ?


wdDoNotSaveChanges

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Thu Nov 27, 2008 2:39 pm

driessen wrote:After my document is closed, I want to make the Word-session invisible. I do this by using this code :
Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 83 guests