"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
>
>
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
"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001d7...@blueyonder.co.not-this-bit.uk...
Thanks.
"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001d7...@blueyonder.co.not-this-bit.uk...
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.
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...
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.
Sorry, the scrollbars appear normally but someone who wrote the app I am
maintaining now supressed other workbooks and the scrollbars.
Thanks!