Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TOleContainer and Excel

240 views
Skip to first unread message

Fabio Santos

unread,
Oct 22, 2003, 11:34:13 AM10/22/03
to
I forgot to mention that I am using Delphi 6, Win XP pro and Office XP.


"Fabio Santos" <fsa...@grahamcapital.com> wrote in message
news:3f96a32f$1...@newsgroups.borland.com...
> Hi, I am using TOleContainer to embed an Excel spreadsheet. I simply
use
> "CreateObjectFromFile" and "DoVerb(ovShow)" methods. The problem is when I
> try to run MS-Excel to edit another spreadsheet when my app is running
> displaying the spreadsheet in the OleContainer, I simply can't. The Excel
> starts but won't open the spreadsheet. Another problem is that if I click
in
> one cell before the spreadsheet is fully loaded inside the OleContainer, I
> get an "OLE Error" message. Does anybody know what's going on? I need some
> general guidelines on how to use Excel inside TOleContainer.
>
> Thank you very much!
>
> Fabio Santos
>
>


Fabio Santos

unread,
Oct 22, 2003, 11:33:03 AM10/22/03
to

Deborah Pate (TeamB)

unread,
Oct 22, 2003, 11:45:27 AM10/22/03
to
<<Fabio Santos:

The problem is when I try to run MS-Excel to edit another
spreadsheet when my app is running displaying the
spreadsheet in the OleContainer, I simply can't.
>>

Yes. There is a problem with using the TOleContainer if
other instances of Excel will be used. The best solution is
to use the OnDeactivate and OnActivate events of your
application to call Olecontainer.Close and
OleContainer.DoVerb (or Run) respectively. (NB it must be
the events of the application, not of the form - you can
use the TApplicationEvents component for this.) That way
when the user switched to Excel, the olecontainer would
close its instance of Excel - without losing its own
contents - and allow the other instance to function
normally.

One possible drawback is that OleContainer.Close saves the
workbook, but if you need to use TOleContainers and Excel
together I think you'll have to live with that.

--
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


Fabio Santos

unread,
Oct 22, 2003, 1:14:11 PM10/22/03
to

I will try that. Thank you very much!

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001d7...@blueyonder.co.not-this-bit.uk...

Fabio Santos

unread,
Oct 22, 2003, 1:17:44 PM10/22/03
to
One more thing so, there is no way of using Excel while a spreadsheet is
open in an OleContainer, right? That's what I wanted to be able to do.

Thanks.

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001d7...@blueyonder.co.not-this-bit.uk...

Deborah Pate (TeamB)

unread,
Oct 22, 2003, 1:46:35 PM10/22/03
to
<<Fabio Santos:

One more thing so, there is no way of using Excel while a
spreadsheet is open in an OleContainer, right? That's what
I wanted to be able to do.
>>

FWIW you can easily start a separate issue of Excel while
the TOleContainer is running, if you run it by using the
Start menu. Trouble comes if you try to start it by
doubleclicking on a workbook. You can fix that simply by
changing the default action (Open) for the .xls file type
so that it doesn't use DDE.

That might be enough to solve your problem. But if it is
possible for the user to start your app when an existing
instance of Excel is already open, then you will have
problems again.

Fabio Santos

unread,
Oct 22, 2003, 2:07:33 PM10/22/03
to

Deborah, I appreciate all your help. I only have 2 more questions:
-How to display scrollbars within an OleContainer?
-The problems I am experiencing, is related to Excel itself or could
happen with any other application? It is a OLE 2 issue? Are there
alternatives?

Thank you so much!

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001d7...@blueyonder.co.not-this-bit.uk...

Deborah Pate (TeamB)

unread,
Oct 22, 2003, 2:25:50 PM10/22/03
to
<<Fabio Santos:

-How to display scrollbars within an OleContainer?
>>

I'm not sure what your problem is here - they appear
automatically after DoVerb(ovShow), don't they?

<<Fabio:


-The problems I am experiencing, is related to Excel
itself or could happen with any other application?
>>

Excel is particularly bad. The problem of starting a second
instance of Excel when the olecontainer is running doesn't
happen with other apps that I can think of. However the
problem when an olecontainer starts after an app is running
happens with other applications. An olecontainer uses a
running instance of an application, if it finds one in the
Running Object Table (ROT) when it starts up, so problems
with applications (such as MS Word) that register
themselves in the ROT are quite likely.

Fabio Santos

unread,
Oct 22, 2003, 2:34:28 PM10/22/03
to
> <<Fabio Santos:
> -How to display scrollbars within an OleContainer?
> >>
>
> I'm not sure what your problem is here - they appear
> automatically after DoVerb(ovShow), don't they?
>

Sorry, the scrollbars appear normally but someone who wrote the app I am
maintaining now supressed other workbooks and the scrollbars.

Thanks!


0 new messages