Home > Archive > Getting Started with dBASE > March 2006 > Closing Excel in dbase form









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Closing Excel in dbase form
Rick Johnson

2006-03-24, 11:24 am

dBase 5.7 NT

I open Excel from within a form using :
cworkpath = "c:\visualdb\tcdtcr\"
cfilename = cworkpath + "xlmaster.xls"

#define xxxxx htoi('18') && open the worksheet
oexcel = new OleAutoClient("Excel.Application")
p = oexcel
p.visible = .t.
p.workbooks.open(( cfilename ))

Then I fill in some in some information and am ready to close the form.
use :
oexcel.activesheet.saveas(( cfilename ))
oexcel.workbooks.close()
oexcel.quit()
oexcel = null
release oexcel

This will close the form, but leaves the EXCEL program in memory, taking up resources. In fact, from my program, I often have 20 or more copies of Excel open in memory at the same time. The Excel program is removed from memory when I exit dBase.

So, does anyone know the command to close Excel and remove it from memory? Thanks in advance

Rick Johnson
David Kerber

2006-03-24, 8:24 pm

In article <EK9MH81TGHA.560@news-server>, rjohnson@bbandt.com says...

....

> oexcel.activesheet.saveas(( cfilename ))
> oexcel.workbooks.close()
> oexcel.quit()
> oexcel = null
> release oexcel
>
> This will close the form, but leaves the EXCEL program in memory, taking up resources. In fact, from my program, I often have 20 or more copies of Excel open in memory at the same time. The Excel program is removed from memory when I exit dBase.
>
> So, does anyone know the command to close Excel and remove it from memory? Thanks in advance


This is really just a guess, but try reversing the order of your last
two lines. I don't think it will be able to release an object if you've
already nulled it out.


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Rick Johnson

2006-03-24, 8:24 pm

David Kerber Wrote:

> In article <EK9MH81TGHA.560@news-server>, rjohnson@bbandt.com says...
>
> ...
>
>
> This is really just a guess, but try reversing the order of your last
> two lines. I don't think it will be able to release an object if you've
> already nulled it out.
>
>
>

Tried it but no luck. Thanks for trying to help...Rick

Roland Wingerter

2006-03-25, 9:24 am

Rick Johnson wrote

>
> So, does anyone know the command to close Excel and remove it from memory?

-------
Check out this article in the dBASE Bulletin:
http://www.jpmartel.com/bu20_c.htm

Roland


Rick Johnson

2006-03-26, 1:23 pm

Roland Wingerter Wrote:

> Rick Johnson wrote
> -------
> Check out this article in the dBASE Bulletin:
> http://www.jpmartel.com/bu20_c.htm
>
> Roland
>
> Thanks for the tip, Roland. I read the article and tried what it said in every way possible. Still no luck. I even tried a 5 second delay after "nulling" the object to give the system time to eliminate the occurance from memory, but no luck. Any mor

e suggestions would be appreciated.

Roland Wingerter

2006-03-27, 3:23 am

Rick Johnson wrote

> Any more suggestions would be appreciated.

------
Sorry, I don't have any.

Roland


Maurice Abraham

2006-03-27, 7:26 am

Hello,

I didn't know if this can help you, because i'ma very bad user. In Dbase
language reference we can read :
"Once you create the OleAutoClient object, the properties, events, and
methods the OLE automation server

provides are accessed through the OleAutoClient object, just as with stock
dBASE Plus objects. You can also

inspect( ) the OleAutoClient object's properties"

It is perhaps a propertie that close the applicalion that we have opened,
and only after we releasead the object.

I am nul in dbl,but i think that:

oexcel.workbooks.close() // close the sheet but not the application itself
oexcel.quit() // delete the link with oexcel, but this order don't
close the application

So, i think that you close the dbase object, but not the calling application
itself, and so she is always in memory.

With inspect(), you can perhaps find a good order to close the application
as we can made with "ALT" + F4

Sorry for my english

Maurice

(france)





"Roland Wingerter" <ich@hier.de> a écrit dans le message de news:
Os2K47XUGHA.1740@news-server...
> Rick Johnson wrote
> ------
> Sorry, I don't have any.
>
> Roland
>



Rick Gearardo

2006-03-30, 8:24 pm

Declare p as a local variable you should not have a problem.

Rick


"Rick Johnson" <rjohnson@bbandt.com> wrote in message
news:EK9MH81TGHA.560@news-server...
> dBase 5.7 NT
>
> I open Excel from within a form using :
> cworkpath = "c:\visualdb\tcdtcr\"
> cfilename = cworkpath + "xlmaster.xls"
>
> #define xxxxx htoi('18') && open the worksheet
> oexcel = new OleAutoClient("Excel.Application")
> p = oexcel
> p.visible = .t.
> p.workbooks.open(( cfilename ))
>
> Then I fill in some in some information and am ready to close the form.
> use :
> oexcel.activesheet.saveas(( cfilename ))
> oexcel.workbooks.close()
> oexcel.quit()
> oexcel = null
> release oexcel
>
> This will close the form, but leaves the EXCEL program in memory, taking
> up resources. In fact, from my program, I often have 20 or more copies of
> Excel open in memory at the same time. The Excel program is removed from
> memory when I exit dBase.
>
> So, does anyone know the command to close Excel and remove it from memory?
> Thanks in advance
>
> Rick Johnson



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com