 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Terry Watts Guest
|
Posted: Fri Sep 17, 2004 4:59 am Post subject: TOleContainer and TWordApplication |
|
|
I have an TOleContainer which I have fired up with Word in it and I would
like to hook a TWordApplication to the copy of Word that is running in the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in another
application or throws access violations.
Thanks in advance.
Terry
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Fri Sep 17, 2004 5:12 am Post subject: Re: TOleContainer and TWordApplication |
|
|
When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote
| Quote: | I have an TOleContainer which I have fired up with Word in it and I would
like to hook a TWordApplication to the copy of Word that is running in the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Terry Watts Guest
|
Posted: Fri Sep 17, 2004 5:22 am Post subject: Re: TOleContainer and TWordApplication |
|
|
Does this mean I cant't hook the TWordApplication to it? Or if it mean I
can, how do I hook them together?
Regards
Terry.
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote
| Quote: | When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a6f4b (AT) newsgroups (DOT) borland.com...
I have an TOleContainer which I have fired up with Word in it and I would
like to hook a TWordApplication to the copy of Word that is running in
the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Terry Watts Guest
|
Posted: Fri Sep 17, 2004 5:30 am Post subject: Re: TOleContainer and TWordApplication |
|
|
I just found TWordApplication as a member of OleObject.
Thanks
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote
| Quote: | Does this mean I cant't hook the TWordApplication to it? Or if it mean I
can, how do I hook them together?
Regards
Terry.
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:414a730a (AT) newsgroups (DOT) borland.com...
When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a6f4b (AT) newsgroups (DOT) borland.com...
I have an TOleContainer which I have fired up with Word in it and I
would
like to hook a TWordApplication to the copy of Word that is running in
the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Terry Watts Guest
|
Posted: Fri Sep 17, 2004 5:43 am Post subject: Re: TOleContainer and TWordApplication |
|
|
It disappeared.
Breifly the Code Insight showed it as a member of OleObject but now it
doesn't, so, I once again don't know how to use it.
Regards
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote
| Quote: | I just found TWordApplication as a member of OleObject.
Thanks
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a74a8 (AT) newsgroups (DOT) borland.com...
Does this mean I cant't hook the TWordApplication to it? Or if it mean I
can, how do I hook them together?
Regards
Terry.
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:414a730a (AT) newsgroups (DOT) borland.com...
When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a6f4b (AT) newsgroups (DOT) borland.com...
I have an TOleContainer which I have fired up with Word in it and I
would
like to hook a TWordApplication to the copy of Word that is running in
the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Fri Sep 17, 2004 9:07 am Post subject: Re: TOleContainer and TWordApplication |
|
|
Just call methods as for WordApplication (late binding):
yourTOLEContainer.OLEObject.ActiveDocument.Range.InsertAfter('new inserted
text');
--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote
| Quote: | It disappeared.
Breifly the Code Insight showed it as a member of OleObject but now it
doesn't, so, I once again don't know how to use it.
Regards
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a7692 (AT) newsgroups (DOT) borland.com...
I just found TWordApplication as a member of OleObject.
Thanks
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a74a8 (AT) newsgroups (DOT) borland.com...
Does this mean I cant't hook the TWordApplication to it? Or if it mean
I
can, how do I hook them together?
Regards
Terry.
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:414a730a (AT) newsgroups (DOT) borland.com...
When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a6f4b (AT) newsgroups (DOT) borland.com...
I have an TOleContainer which I have fired up with Word in it and I
would
like to hook a TWordApplication to the copy of Word that is running
in
the
TOleContainer. Is there a way to do this, as all the ways I try throw
exceptions saying that I can't control Word as it is running in
another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Terry Watts Guest
|
Posted: Fri Sep 17, 2004 10:09 pm Post subject: Re: TOleContainer and TWordApplication |
|
|
If I try this I get an exception : "Method ActiveDocument not supported by
automation object ".
As this is the first time I have tried to automate anything I would really
prefer to uses the TWordApplication as the Code Insight gives me an idea of
what I can and can't do with the Word object, but with using a variant I'm
flying blind. What I would like to do is to embed the word application
within my own application and have it display in and area within my own
form, which I can do with TOleContainer but can't find a way to do with
TWordApplication.
Regards
Terry
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote
| Quote: | Just call methods as for WordApplication (late binding):
yourTOLEContainer.OLEObject.ActiveDocument.Range.InsertAfter('new inserted
text');
--
With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a798d (AT) newsgroups (DOT) borland.com...
It disappeared.
Breifly the Code Insight showed it as a member of OleObject but now it
doesn't, so, I once again don't know how to use it.
Regards
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a7692 (AT) newsgroups (DOT) borland.com...
I just found TWordApplication as a member of OleObject.
Thanks
Terry.
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a74a8 (AT) newsgroups (DOT) borland.com...
Does this mean I cant't hook the TWordApplication to it? Or if it mean
I
can, how do I hook them together?
Regards
Terry.
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:414a730a (AT) newsgroups (DOT) borland.com...
When you'll load your Word-document, you may use
yourOLEContainer.OleObject - this is an instance for WordApplication
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Terry Watts" <TerryWatts (AT) bigpond (DOT) com> wrote in message
news:414a6f4b (AT) newsgroups (DOT) borland.com...
I have an TOleContainer which I have fired up with Word in it and I
would
like to hook a TWordApplication to the copy of Word that is running
in
the
TOleContainer. Is there a way to do this, as all the ways I try
throw
exceptions saying that I can't control Word as it is running in
another
application or throws access violations.
Thanks in advance.
Terry
|
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Sat Sep 18, 2004 8:46 am Post subject: Re: TOleContainer and TWordApplication |
|
|
<
If I try this I get an exception : "Method ActiveDocument
not supported by automation object ".
Because the object in a container is a Document, not the
Word Application object. So you never have to use the
ActiveDocument method - you've already got the active
document. If you want to get at the application you use the
Document's Application property.
<
As this is the first time I have tried to automate anything
I would really prefer to uses the TWordApplication as the
Code Insight gives me an idea of what I can and can't do
with the Word object, but with using a variant I'm
flying blind.
You can use interfaces rather than variants to achieve
this.
uses
Word2000; // or whichever version you want to use
var
Doc: _Document;
Word: _Application;
...
Doc := IDispatch(OleContainer1.OleObject) as _Document;
Word := Doc.Application;
Using interfaces means you get compile-time checking and
Code Insight help, without having two components fighting
over the same instance of Word.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| Back to top |
|
 |
Terry Watts Guest
|
Posted: Sun Sep 19, 2004 12:03 pm Post subject: Re: TOleContainer and TWordApplication |
|
|
This works a treat but this leads me to some other questions about
automating Word.
Because I have a Word document in the container rather than Word itself
there seems to be no way to load an existing document into it. If I try
using the Word interface rather than the Documnet interface to open the
existing file I get the exception "Method or Property is unavailable as the
document is in another application.". So I gess my question is how does one
open an existing document into the Word document in the OleContainer?
Thanks
Terry.
"Deborah Pate (TeamB)" <d.pate (AT) blueyonder (DOT) co.not-this-bit.uk> wrote in
message news:VA.00001efa.0040670f (AT) blueyonder (DOT) co.not-this-bit.uk...
| Quote: | Terry Watts:
If I try this I get an exception : "Method ActiveDocument
not supported by automation object ".
Because the object in a container is a Document, not the
Word Application object. So you never have to use the
ActiveDocument method - you've already got the active
document. If you want to get at the application you use the
Document's Application property.
Terry:
As this is the first time I have tried to automate anything
I would really prefer to uses the TWordApplication as the
Code Insight gives me an idea of what I can and can't do
with the Word object, but with using a variant I'm
flying blind.
You can use interfaces rather than variants to achieve
this.
uses
Word2000; // or whichever version you want to use
var
Doc: _Document;
Word: _Application;
..
Doc := IDispatch(OleContainer1.OleObject) as _Document;
Word := Doc.Application;
Using interfaces means you get compile-time checking and
Code Insight help, without having two components fighting
over the same instance of Word.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
|
| Back to top |
|
 |
Deborah Pate (TeamB) Guest
|
Posted: Sun Sep 19, 2004 1:45 pm Post subject: Re: TOleContainer and TWordApplication |
|
|
<
So I gess my question is how does one open an existing
document into the Word document in the OleContainer?
Since the TOleContainer is hosting the document, it needs
to be responsible for opening, saving, and closing it, so
you call its methods for those things, not Word's: e.g.
CreateObjectFromFile and SaveAsDocument.
--
Deborah Pate (TeamB) http://delphi-jedi.org
TeamB don't see posts sent via Google or ISPs
Use the real Borland server: newsgroups.borland.com
http://www.borland.com/newsgroups/genl_faqs.html
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|