Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help on closing object properly

I've made an application in VB 6.0. From this I do the following:

1.
Open specific Excel-file

2.
Automatically insert data into the now open Excel, based on values in
the VB-application.

3.
Cut all bonds to the Excel-application, but leave it open for further
work and saving.

4.
It should be possible to close the Excel file doing the above several
times.

This is what I use to open:

---code begin
Dim xlo As excel.Application
Dim xloW As excel.Workbook

Dim myCount As Integer, x As Integer, NewMeasure As Integer
Dim isEven As Boolean

If xlo Is Nothing Then
Set xlo = New excel.Application
Else
Set xlo = excel.Application
End If
Set xloW = xlo.Workbooks.Open("u:\excel\kontrolkort.xls")
xloW.Application.Visible = True
...
---code end

Currently I have a "Set xlo = Nothing" at the end. But if I close
Excel, Excel is not visible but I can see it as a running process. If
I attempt to open it again through my VB-app it errors.

Am I approacihing it wrongly?



Regards /Snedker
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help on closing object properly

Set xlo = Nothing just clears the variable.
Try

xlo.Quit

If I understand what you're trying to do, that should be what you want.
- Pikus


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Help on closing object properly

On Tue, 23 Dec 2003 16:44:29 -0600, pikus
wrote:

Set xlo = Nothing just clears the variable.
Try

xlo.Quit

If I understand what you're trying to do, that should be what you want.


xlo.Quit makes the Excel application want to quit. I wish to keep
working in it...?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help on closing object properly

Or xloW.Close then.

Maybe I'm just not understanding what you're trying to close and why...
- Pikus


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default Help on closing object properly

Hi,
When Excel remains visible in the task list it is usualy because you've used
an Excel global object.

Ex: MyValue=range("a1").value will work from VB6 but only because "range" is
a global object exposed by Excel's object model.
AKA implicit object.
Ex: MyValue=xlo.range("a1").value is an explicit object and will be set to
nothing when xlo is.

On your second point if you set xlo=nothing or close the Excel session the
only way to "reconnect" is to use getobject(). Re-running Set xlo = New
excel.Application will alway create a NEW session & NEW object.

See getobject() in VB6 help for a code example to test for a running Excel
object or create a new object if Excel is not running.


--
John

johnf202 at hotmail dot com



"Snedker" wrote in message
...
I've made an application in VB 6.0. From this I do the following:

1.
Open specific Excel-file

2.
Automatically insert data into the now open Excel, based on values in
the VB-application.

3.
Cut all bonds to the Excel-application, but leave it open for further
work and saving.

4.
It should be possible to close the Excel file doing the above several
times.

This is what I use to open:

---code begin
Dim xlo As excel.Application
Dim xloW As excel.Workbook

Dim myCount As Integer, x As Integer, NewMeasure As Integer
Dim isEven As Boolean

If xlo Is Nothing Then
Set xlo = New excel.Application
Else
Set xlo = excel.Application
End If
Set xloW = xlo.Workbooks.Open("u:\excel\kontrolkort.xls")
xloW.Application.Visible = True
...
---code end

Currently I have a "Set xlo = Nothing" at the end. But if I close
Excel, Excel is not visible but I can see it as a running process. If
I attempt to open it again through my VB-app it errors.

Am I approacihing it wrongly?



Regards /Snedker





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"