🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #341

Re: OLE with Excel

#341
From: Bill Amend
Date: Thu, 11 Sep 1997 00:00
98 lines
3814 bytes

This is a multi-part message in MIME format.
--------------422B3964242D07F6B8B12C28
Content-Type: text/plain; charset=us-ascii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Transfer-Encoding: 7bit

Rob_Johansen@grandcasinosinc.com wrote:

> Please help! I am learing about OLE for a project tha I am starting.
> I
> will need to be interfacing with Excel. First things first, can people
>
> recommend a good book or other sources of information on OLE
> automation
> with Excel?  Specificly, for right now, I need information on using
> the
> OleContainer and the OleObject with Excel.  Almost all examples I have
>
> are for Word.
>
> My current problems: (after only 3 days) 1)  With the OleContainer.
> How
> do you deactivate the container?  If I issue a DoVerb(ovHide), it
> hides
> the spreadsheet, but leaves the container active, Excel menus and all.
>
> 2)  With the OleObject.  Similar problem.  when I do a v.Quit (v =
> variant) after I have done something to the spreadsheet, Excel will
> not
> quit without asking if I want to save the changes.  I don't want to.
> I
> know that doesn't make sense on it's own, but it does in "the big
> picture".  Can I tell the Excel dialog (or assistant) 'No", can I tell
>
> Excel to quit without asking?
>
> 3)  Connecting the two.  I want to use oleautomation on an Excel
> OleContainer by using the OleContainer1.OleObject.  The only example I
>
> have is for Word:  var  v : Variant;  begin
> OleContainer1.DoVerb(ovShow);  v := OleContainer1.OleObject;  v :=
> v.Application.WordBasic;  {<- note: no '.' in WordBasic }
> v.Insert('text');  end; I have tried to replace the "WordBasic" with
> "ExcelApplication", "ExcelSheet", "ExcelApplication8",
> "Excel.Application", "Excel.Sheet", etc.  All that happens is that my
> application seems to lock up.
>
> I would appreciate any help with this,  even though I know that they
> are
> probably stupid questions.
>
> thanks,
>   --Rob
>
> -------------------==== Posted via Deja News
> ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

Attached below is a simple example.  Good luck.

Bill Amend



--------------422B3964242D07F6B8B12C28
Content-Type: text/plain; charset=us-ascii; name="example.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="example.txt"

  var
     v:  variant;
  begin
   v:= CreateOleObject('Excel.Application');
   v.workbooks.open ('d:\hysys1\cases\stmprop1.xls'); }
   v.visible := true;
   v.run ('setup1'); {run macro called setup1()} 
   v.range('pin').value := 690.0;
   v.range('tin').value := -171.0;
   v.range('pout').value := 670.0;
   v.range('eff').value := 0.60;
  { v.run ('calculate');  }
    rhog_x := v.range('SIDens').value ;
    rhol_x :=v.range('EngDens').value  ;
    hl_x := v.range('EngEnth').value  ;
    hl_x := v.range('SIEnth').value  ;
    mul_x := v.range('EngVisc').value  ;
    mug_x := v.range('SIVisc').value  ;
    sig_x  :=  v.range('ST_LIQ').value  ;
  { v.application.sheets.add; }
   {v.workbook.save;    }
   v.workbooks.close ;

  end;

--------------422B3964242D07F6B8B12C28--
Technical Details
Message-ID: <3418176D.2B7B6AAF@flash.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <873908115.17313@dejanews.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10baee,6cedd6b603d1c1f8
X-Google-Attributes: gid10baee,public
X-Google-Thread: fd196,6cedd6b603d1c1f8
X-Google-Attributes: gidfd196,public
From: Bill Amend <billybob@flash.net>
Subject: Re: OLE with Excel
Date: 1997/09/11
Message-ID: <3418176D.2B7B6AAF@flash.net>
X-Deja-AN: 271665814
References: <873908115.17313@dejanews.com>
X-Priority: 3 (Normal)
Organization: Flashnet Communications, http://www.flash.net
Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.oleautomation