Board index » delphi » Process Id Problem Again... (Please help Team B)

Process Id Problem Again... (Please help Team B)


2004-08-09 01:25:28 PM
delphi247
Hi,
I am repeating my post again as i have not yet got any response.
If u need any more information regarding my problem please ask.
I am willing to help u help me.
Im using Delphi 5 and workin on OLEAutomation.
I have created a Word application thru Late Binding.
I have a problem when i close this application using the 'Quit' method of word application.
It closes all the running instances of Word Applications outside my Application.
I think i can target the word application created by me thru code using its Process Id (which is different from the Process Id of my .exe that creates it).
Please help me to find the Process Id of the word application created my me (I repeat it is not the process Id of my exe that creates it).
Also using this Process Id , how do i close the Word Application I created ... without affecting the running instances of Word Application(outside my Application).
 
 

Re:Process Id Problem Again... (Please help Team B)

<<Sundip:
I am repeating my post again as i have not yet got any
response. If u need any more information regarding my
problem please ask.
Quote
>
Your Word version could be important. At any rate, if
you're using Word2000+, it seems likely that you are not
closing different instances of Word, but merely different
documents opened by that instance. If that is so, you just
have to refrain from closing Word if there are other
documents open (of course you should Disconnect your
component when you've finished with it). If not, could you
tell us how these instances are started, and how you close
them?
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:Process Id Problem Again... (Please help Team B)

Quote

Your Word version could be important. At any rate, if
you're using Word2000+,it seems likely that you are not
closing different instances of Word, but merely different
documents opened by that instance. If that is so, you just
have to refrain from closing Word if there are other
documents open (of course you should Disconnect your
component when you've finished with it). If not, could you
tell us how these instances are started, and how you close
them?
thx and hi,
i am using Word 2000+. Preferably I'd like to use any version of Word.
i'll start out by telling what exactly im doing.
I am trying to integrate Word Application in a form using OLE Container.
I am doing this by late binding.
I have created an OleVariant 'wordApp' and i instantiated it by
OleContainer1.CreateObjectFromFile(strTempFile,False);
OleContainer1.DoVerb(ovShow);
wordApp := OleContainer1.OleObject.Application;
on close of the form i have tried various stuff
1] wordApp.Quit; // this closes all the running instances of word
2] wordApp.ActiveWindow.Close(EmptyParam, EmptyParam); //this gives "Command is not available" run-time error
With reference to point 2... this same command works if wordApp had been an Excel Application. here im able to close only my excel instance and the other excel instances(outside my application) are unharmed.
Please ask if u need any more clarifications.
Thx for ur time and help.
-Sundip
 

Re:Process Id Problem Again... (Please help Team B)

Quote
2] wordApp.ActiveWindow.Close(EmptyParam, EmptyParam); //this
gives "Command is not available" run-time error
Personally I use:
wordapp.activedocument.close(emptyparam, emptyparam, False);
Oliver Townshend
 

Re:Process Id Problem Again... (Please help Team B)

<<Sundip:
using OLE Container.
Quote
>
Aaargh! This is an important piece of information to
include in your messages. :)
The TOleContainer will use a running instance of Word, and
AFAIK there is nothing you can do about this. So don't
close Word; just close your document, using the
OleContainer.Close method. (Note that this method saves the
document.)
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:Process Id Problem Again... (Please help Team B)

<< Team B:
Quote
The TOleContainer will use a running instance of Word, and
AFAIK there is nothing you can do about this. So don't
close Word; just close your document, using the
OleContainer.Close method. (Note that this method saves the
document.)
thx and hi,
Do you mean to say that I will have to take care there is not Word instances running before i start my application (instantiate my word applicatio).
How does the code
Application.ActiveWindow.Close(EmptyParam, EmptyParam);
work for Excel Applications. in Excel im able to close my applications without harming the other running instances... how so.
- Sundip
 

Re:Process Id Problem Again... (Please help Team B)

<<Sundip:
Do you mean to say that I will have to take care there is not
Word instances running before i start my application
Quote
>
I just meant what I said - close the document, but not Word
(you don't need to close it). There can be other problems
with running Word at the same time as a document in a
TOleContainer, so I would avoid it if possible, but you haven't
mentioned having them.
<<Sundip:
in Excel im able to close my applications
Quote
>
In general you cannot argue from one application to another
in this way, since they vary in object model, whether they
register themselves in the Running Object Table, and so on.
But calling Excel.Quit certainly does close the previously
existing instance of Excel when I run it, so I can not say
for certain what's going on with yours.
--
Deborah Pate (TeamB) delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
www.borland.com/newsgroups/genl_faqs.html
 

Re:Process Id Problem Again... (Please help Team B)

<<Oliver Townshend
Quote
Personally I use:
wordapp.activedocument.close(emptyparam, emptyparam, False);
thx and hello oliver,
i m using TOleContainer.
and when i close the document in my form close by,
wordapp.activedocument.close(emptyparam, emptyparam, False);
i get a run time error sayin
"This method or property id not available brcause this document is in another application"
- Sundip