Board index » delphi » Embeded excel

Embeded excel

hi ,

  I would like to open the excel on my form ...embeded

  I tried a few examples but all of them with out success...

 here is one from Deborah Pate ; (Deborah if u can help...)

var
    Excel: Variant;
  begin
    try
      Excel := GetActiveOleObject('Excel.Application');
    except
      Excel := CreateOleObject('Excel.Application');
    end;
    Excel.Visible := True;

  in this case excel does not start and i can not see it...(I have
checked in the processes area in the task manager too)

  but I would like it to be visible on the screen so I try to work with
OLEContainer ...no success yet..

 if someone can give an example it will be helpful

regards,
paz

 

Re:Embeded excel


<<Paz88:
  in this case excel does not start and i can not see it..

Quote

If Excel is installed correctly on your machine,  
CreateOleObject('Excel.Application') should start it. If it
doesn't there is something wrong with your setup.

To use a TOleContainer, you can either create a new sheet:
  OleContainer1.CreateObject('Excel.Sheet', true);
  OleContainer1.DoVerb(ovShow);
or load an existing sheet:
  OleContainer1.CreateObjectFromFile(
         'C:\My Documents\Book1.xls', False);
  OleContainer1.DoVerb(ovShow);

Again, if it doesn't work, it's a problem with your Excel
installation.

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

    Thanx ,

        I succeeded and would like to read from this excel cells ...

        how do I read from it..

Regards,
paz .

Quote
"Deborah Pate (TeamB)" wrote:
> <<Paz88:
>   in this case excel does not start and i can not see it..

> If Excel is installed correctly on your machine,
> CreateOleObject('Excel.Application') should start it. If it
> doesn't there is something wrong with your setup.

> To use a TOleContainer, you can either create a new sheet:
>   OleContainer1.CreateObject('Excel.Sheet', true);
>   OleContainer1.DoVerb(ovShow);
> or load an existing sheet:
>   OleContainer1.CreateObjectFromFile(
>          'C:\My Documents\Book1.xls', False);
>   OleContainer1.DoVerb(ovShow);

> Again, if it doesn't work, it's a problem with your Excel
> installation.

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

    succeeded ...

    that way :

        ExcelRates := RatesContainer.OleObject.Application;
  RatesWindow := ExcelRates.ActiveWindow;
  SQLRateString :=  RatesWindow.cells.item[1,1].value ; ;

paz.

Quote
paz88 wrote:
> Hi ,

>     Thanx ,

>         I succeeded and would like to read from this excel cells ...

>         how do I read from it..

> Regards,
> paz .

> "Deborah Pate (TeamB)" wrote:

> > <<Paz88:
> >   in this case excel does not start and i can not see it..

> > If Excel is installed correctly on your machine,
> > CreateOleObject('Excel.Application') should start it. If it
> > doesn't there is something wrong with your setup.

> > To use a TOleContainer, you can either create a new sheet:
> >   OleContainer1.CreateObject('Excel.Sheet', true);
> >   OleContainer1.DoVerb(ovShow);
> > or load an existing sheet:
> >   OleContainer1.CreateObjectFromFile(
> >          'C:\My Documents\Book1.xls', False);
> >   OleContainer1.DoVerb(ovShow);

> > Again, if it doesn't work, it's a problem with your Excel
> > installation.

> > --
> > Deborah Pate (TeamB) http://delphi-jedi.org

> >   Use Borland servers; TeamB don't see posts via ISPs
> >   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

    My computer is stuck on the last order here :

     SQLRateString :=  RatesWindow.cells.item[1,1].value ;

 cpu jumps to 100% and nothing happened ...why ?

Paz

Quote
paz88 wrote:
> Hi ,

>     succeeded ...

>     that way :

>         ExcelRates := RatesContainer.OleObject.Application;
>   RatesWindow := ExcelRates.ActiveWindow;
>   SQLRateString :=  RatesWindow.cells.item[1,1].value ; ;

> paz.

> paz88 wrote:

> > Hi ,

> >     Thanx ,

> >         I succeeded and would like to read from this excel cells ...

> >         how do I read from it..

> > Regards,
> > paz .

> > "Deborah Pate (TeamB)" wrote:

> > > <<Paz88:
> > >   in this case excel does not start and i can not see it..

> > > If Excel is installed correctly on your machine,
> > > CreateOleObject('Excel.Application') should start it. If it
> > > doesn't there is something wrong with your setup.

> > > To use a TOleContainer, you can either create a new sheet:
> > >   OleContainer1.CreateObject('Excel.Sheet', true);
> > >   OleContainer1.DoVerb(ovShow);
> > > or load an existing sheet:
> > >   OleContainer1.CreateObjectFromFile(
> > >          'C:\My Documents\Book1.xls', False);
> > >   OleContainer1.DoVerb(ovShow);

> > > Again, if it doesn't work, it's a problem with your Excel
> > > installation.

> > > --
> > > Deborah Pate (TeamB) http://delphi-jedi.org

> > >   Use Borland servers; TeamB don't see posts via ISPs
> > >   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


<<Paz88:
cpu jumps to 100% and nothing happened ...why ?

Quote

Because it's no use using the ActiveWindow property like
that with an olecontainer. Access the worksheet:

var
  WS: OleVariant;
begin
  WS := OleContainer1.OleObject.Worksheets[1];
  Caption := WS.Cells.Item[1, 1].Text;

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

  another one ..

   I have references in the worksheet and i get the question "if those
macros should be updated when open yes / no " how can i avoid
   it ?

   strange but when the app starts all those references (which are dde
links) shows #REF ...then I close the app and the excel

   is still running as an invisible  process and then when I open the
app again the links are working i.e. show data ...

   any idea why ...

Regards,
paz .

Quote
"Deborah Pate (TeamB)" wrote:
> <<Paz88:
> cpu jumps to 100% and nothing happened ...why ?

> Because it's no use using the ActiveWindow property like
> that with an olecontainer. Access the worksheet:

> var
>   WS: OleVariant;
> begin
>   WS := OleContainer1.OleObject.Worksheets[1];
>   Caption := WS.Cells.Item[1, 1].Text;

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

  thanks again ..

   I am using the idea like that :

  RatesSheet := RatesContainer.OleObject.WorkSheets[1];
  RatesSheet.cells.item[1,1].value ;

  till here everything is fine but

                        With RatesSheet.cells do begin

  give an error that an "object or  class type "  is  required...

  any type cast that i tried is not working...any idea

Regards,
paz

Quote
"Deborah Pate (TeamB)" wrote:
> <<Paz88:
> cpu jumps to 100% and nothing happened ...why ?

> Because it's no use using the ActiveWindow property like
> that with an olecontainer. Access the worksheet:

> var
>   WS: OleVariant;
> begin
>   WS := OleContainer1.OleObject.Worksheets[1];
>   Caption := WS.Cells.Item[1, 1].Text;

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


<<Paz88:
any type cast that i tried is not working...any idea

Quote

Yes, don't do it, it isn't allowed. You can use a local
variable instead:
var
  Cells: OleVariant;
..
  Cells := Wks.Cells;
  Cells.Item[1, 1].Value := 42;

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


hi ,

  10x , How can hide the menu bar of excel ?

  I have noticed that sometimes the excel is becoming gray and
disable...why ?
Regards,
paz .

Quote
"Deborah Pate (TeamB)" wrote:
> <<Paz88:
> any type cast that i tried is not working...any idea

> Yes, don't do it, it isn't allowed. You can use a local
> variable instead:
> var
>   Cells: OleVariant;
> ..
>   Cells := Wks.Cells;
>   Cells.Item[1, 1].Value := 42;

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


by doing  :

   Container.OleObject.Application.CommandBars['Standard'].visible :=
False ;

I do not see the menu ...

paz

Quote
paz88 wrote:
> hi ,

>   10x , How can hide the menu bar of excel ?

>   I have noticed that sometimes the excel is becoming gray and
> disable...why ?
> Regards,
> paz .

> "Deborah Pate (TeamB)" wrote:

> > <<Paz88:
> > any type cast that i tried is not working...any idea

> > Yes, don't do it, it isn't allowed. You can use a local
> > variable instead:
> > var
> >   Cells: OleVariant;
> > ..
> >   Cells := Wks.Cells;
> >   Cells.Item[1, 1].Value := 42;

> > --
> > Deborah Pate (TeamB) http://delphi-jedi.org

> >   Use Borland servers; TeamB don't see posts via ISPs
> >   http://www.borland.com/newsgroups/genl_faqs.html

Re:Embeded excel


Hi ,

  O.k by using run instead of doverb(ovShow) ...there is no menu bar .

Quote
paz88 wrote:
> hi ,

>   10x , How can hide the menu bar of excel ?

>   I have noticed that sometimes the excel is becoming gray and
> disable...why ?
> Regards,
> paz .

> "Deborah Pate (TeamB)" wrote:

> > <<Paz88:
> > any type cast that i tried is not working...any idea

> > Yes, don't do it, it isn't allowed. You can use a local
> > variable instead:
> > var
> >   Cells: OleVariant;
> > ..
> >   Cells := Wks.Cells;
> >   Cells.Item[1, 1].Value := 42;

> > --
> > Deborah Pate (TeamB) http://delphi-jedi.org

> >   Use Borland servers; TeamB don't see posts via ISPs
> >   http://www.borland.com/newsgroups/genl_faqs.html

Other Threads