|
-
Nov 22nd, 2004, 02:48 AM
#1
Thread Starter
Lively Member
xl not closing
I'm creating a xl worksheet i VB6 using the following code.
Code:
Public objXL As New Excel.Application
Public wbXL As New Excel.Workbook
Public wsXL As New Excel.Worksheet
Set wbXL = Workbooks.Open(App.Path & "\test.xls")
Set wsXL = wbXL.Worksheets.Add(, Worksheets(1))
i close these in this manner.
Code:
wbXL.Save
Set wsXL = Nothing
wbXL.Close False
Set wbXL = Nothing
Set objXL = Nothing
After executing above code, when i open the task manager there still is an instance of xl process in memory.
i hv win xp, vb6 SP5 , office2k. can any1 help
-amresh-
Last edited by Bolerophone; Nov 26th, 2004 at 01:56 AM.
Jobs: "Do u want to sell colored sugar water or change the world?"
Get Firefox Now!!!
Mendhak leaving town. 
-
Nov 22nd, 2004, 07:27 AM
#2
Fanatic Member
This is a a pain yopu would think that by setting the object to nothing it would destory the Excel application but you have to quite the application also.
VB Code:
bXL.Save
Set wsXL = Nothing
wbXL.Close False
Set wbXL = Nothing
'This is what we need
objXL.Quit
Set objXL = Nothing
Hope this helps!!
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
-
Nov 22nd, 2004, 07:53 AM
#3
Re: xl not closing
There is also something else which might cause issues along these lines, which I would strongly recommend changing.
You are referencing Excel based objects, but are not specifying any parent objects, therefore VB will make assumptions (which could easily be incorrect, and may not even reference Excel at all!).
What you should have is this:
VB Code:
Public objXL As New Excel.Application
Public wbXL As New Excel.Workbook
Public wsXL As New Excel.Worksheet
Set wbXL = [b]objXL.[/b]Workbooks.Open(App.Path & "\test.xls")
Set wsXL = wbXL.Worksheets.Add(, [b]wbXL.[/b]Worksheets(1))
-
Nov 23rd, 2004, 12:04 AM
#4
Thread Starter
Lively Member
thanks. I will try these methods.
-Amresh-
Jobs: "Do u want to sell colored sugar water or change the world?"
Get Firefox Now!!!
Mendhak leaving town. 
-
Nov 26th, 2004, 01:52 AM
#5
Thread Starter
Lively Member
resolved
I tried both the methods. However the excel application instance in the task manager does go away however only when I exit my application and not when the function calling objXL.Quit exits.
Well it works for me. Still any insights will be great.
Jobs: "Do u want to sell colored sugar water or change the world?"
Get Firefox Now!!!
Mendhak leaving town. 
-
Nov 26th, 2004, 02:22 AM
#6
maybe set the value of the function to nothing?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|