Ok thanks! That works fine for Word, but a similar techniques fails for
Excel.
I want to pull data from a spreadsheet - and have been trying to test out
the technique using something like the code below. Thiw works fine, insofar
that the data are correctly displayed on the browser, but Excel is still
running afterwards. No error is give, but I need to be able to destroy the
Excel object, or I will be quickly running out of resources!
The code is ...
<?php
echo "
<HTML><HEAD><TITLE>Processing Form</TITLE></HEAD><BODY BGCOLOR=\"#D5D5AB\">
<h1>This is a test</h1>";
$xlApp = new COM("Excel.Application") or Die ("Did not connect");
$workbook = "d:\wwwroot\studentdata\xl1.xls";
$wkb = $xlApp->Workbooks->Open($workbook) or Die ("Did not open");
$sheets = $wkb->Worksheets("Sheet1");
$cell = $sheets->Cells(1,1);
print "Cell Value = {$cell->value} <BR>";
$xlApp->ActiveWorkbook->Close("False");
$xlApp->quit();
$xlApp = null;
echo "</body></html>";
?>
-----Original Message-----
From: Alain Samoun [mailto:[EMAIL PROTECTED]]
Sent: 10 September 2001 19:04
To: Jeff Waldock
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Closing Excel using DCOM and Release()
To close Word, you should use:
$word->quit();
You are right, my PHPBuilder example has an error, thanks for pointing it to
me ;)
Alain
On Mon, Sep 10, 2001 at 06:30:20PM +0100, Jeff Waldock wrote:
> Thanks for the comment, but this code was lifted from an example on
> PHPbuilder.com! The central problem is that the instance of Excel (or
Word)
> does not quit following $word->Quit(); I expected that the ->Release()
> function would release the memory associated with the object, but it
clearly
> doesn't function because, as you say, it is not part of the Excel or Word
> object model. In which case ... how do it destroy the object?
> Jeff Waldock
>
> -----Original Message-----
> From: Alain Samoun [mailto:[EMAIL PROTECTED]]
> Sent: 09 September 2001 21:55
> To: Jeff Waldock
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] Closing Excel using DCOM and Release()
>
>
> As it said, your COM connection is closed, in addition 'release' is not a
> member in the word object as well as in the excel object.
> Alain
>
> On Sun, Sep 09, 2001 at 02:20:35PM +0100, Jeff Waldock wrote:
> > I cannot seem to get PHP to recognise the Release function when tring to
> > close an instance of Excel or Word opened using DCOM.
> >
> > This is the error message returned..
> >
> > Warning: Unable to lookup release: The object invoked has disconnected
> from
> > its clients. in d:\wwwroot\studentdata\word.php on line 21
> >
> > The code on line 21 is just
> > $word->Release();
> >
> > The full code is::
> > <?php
> >
> > // starting word
> > $word = new COM("word.application") or die("Unable to instanciate
Word");
> > print "Loaded Word, version {$word->Version}\n";
> >
> > //bring it to front
> > $word->Visible = 1;
> >
> > //open an empty document
> > $word->Documents->Add();
> >
> > //do some weird stuff
> > $word->Selection->TypeText("This is a test...");
> > $word->Documents[1]->SaveAs("Useless test.doc");
> >
> > //closing word
> > $word->Quit();
> >
> > //free the object
> > $word->Release();
> > $word = null;
> >
> > ?>
> >
> > Where am I going wrong?
> >
> > Jeff Waldock
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]