Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lingering Excel File in Task Manager 3

Status
Not open for further replies.

TheAceMan1

Programmer
Sep 23, 2003
11,174
US
Howdy All! . . .

Platform: Vista Home Premium, Excel 2003 SP3

Have a routine in a workbook whose job it is to get the total count of the number of columns from a number of workbooks. The workbooks all reside in a specific folder and are duplicates of a master ... just different data. The structure of the workbook has a test procedure running down the left side and each column to right holds tester info on each step. Iknow ... I know ... not my design. Just helping a friend.

Anyway the code works fine and returns the proper counts. It'll be a single total count when I get out of the [blue]testing phase[/blue].

The problem: After opening and closing all these files (one by one), windows Task Manager reveals and additional XL file running with the same name as that the code is running in ... Acetest.xls.

Before running the code Task Manager reveals:
[purple]Microsoft Excel-AceTest.xls[/purple]
After the code runs its:
[red]AceTest.xls[/red]
[purple]Microsoft Excel-AceTest.xls[/purple]

I present the code below with a line highlited in [red]red[/red] to show where the additional Task Manager entry 1st appears ... after single stepping in debug mode:
Code:
[blue][green]'Main Routine[/green]
Public Function AllWkBksTltBall()
   Dim fPath As String, curName As String, cnt As Long
   
   fPath = "C:\SpreadSheets\Ballast\"
   curName = Dir(fPath & "*.xls")
   cnt = WkBkTltBall()
   Debug.Print ActiveWorkbook.Name & " " & cnt [green]'This WorkBook[/green]
   
   Do Until curName = ""
      [red][b]Workbooks.Open (fPath & curName)[/b][/red]
      cnt = WkBkTltBall()
      Debug.Print ActiveWorkbook.Name & " " & cnt [green]'File WorkBook[/green]
      ActiveWorkbook.Close
      curName = Dir
   Loop
   
End Function

[green]'Support Routine[/green]
Public Function WkBkTltBall() As Long
   Dim ws As Worksheet, idx As Long, Shts As String, Tlt As Long, WB As Workbook
   
   Shts = "CtlData~Sample"
   
   For Each ws In ActiveWorkbook.Worksheets
      With ws
         If InStr(Shts, ws.Name) = 0 Then
            idx = .Cells(6, .Columns.Count).End(xlToLeft).Column
            If idx = 8 Then idx = 6
               Tlt = Tlt + (idx - 6) / 3
               [green]'Debug.Print ws.Name & " " & (idx - 6) / 3[/green]
         End If
      End With
   Next
   
   WkBkTltBall = Tlt
   
End Function[/blue]
Any Ideas how to get rid of the lingering task? [surprise]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
To All! . . .

Does Excel have an equivalent to [blue]Application Echo[/blue] in Access?

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Does Excel have an equivalent to Application Echo in Access?
Application.ScreenUpdating

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Bump ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
What directory is the master workbook residing in?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
How are ya xlbo . . .
xlbo said:
[blue]What directory is the master workbook residing in?[/blue]
That would be [blue]C:\SpreadSheets\[/blue]. When the master workbook is completed its saved under a new sequential name in [blue]C:\SpreadSheets\Ballast\[/blue], and then the master is cleared for the next set of data.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Looks like a standard task manager behaviour. If you have more than one workbook opened, one extra entry for active workbook appears in task manager applications list, preceded by application name.
It does not happen when the 'show windows on task bar' option is deselected.

combo
 
Looks like combo has the answer!

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
combo, xlbo . . .

Not quite ... Bear in mind [blue]AceTest.xls[/blue] is where the code is running and in a different folder as far as the [blue]Do Loop[/blue] is concerned. In fact its count is initally included with the 1st
Code:
[blue]Cnt = WkBkTltBall() [green]'This WorkBook[/green][/blue]
Before entering the loop Task Manager reveals:
Code:
[blue]Microsoft Excel-AceTest.xls[/blue]
Now ... entering the loop produces the following (opening/closing 3 files in [blue]C:\SpreadSheets\Ballast\[/blue])
Code:
[blue]AceTest.xls
Ball[purple][b]2[/b][/purple].xls
Microsoft Excel - Ball[purple][b]2[/b][/purple].xls

AceTest.xls
Ball[purple][b]3[/b][/purple].xls
Microsoft Excel - Ball[purple][b]3[/b][/purple].xls

AceTest.xls
Ball[purple][b]4[/b][/purple].xls
Microsoft Excel - Ball[purple][b]4[/b][/purple].xls

[green]'After routine completes[/green]
[red]AceTest.xls[/red] [green]'why this guy still running when done?[/green]
Microsoft Excel - AceTest.xls[/blue]
The files in the loop open & close properly and do not show in Task Manager in the end. Just the additional instance/task of AceTest.xls.

See my point? If its suppose to be there I'm just trying to understand it. The extra task puts me in alert mode! [surprise]

[blue]Your Thoughts? . . .[/blue]



See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I guess that the AceTest.xls is still opened.

Do a simple test for two saved workbooks without macros:
1. close excel, open fresh instance,
2. open first workbook,
3. open second workbook,
4. activate first workbook,
5. close first workbook.

After each of 1-5 steps observe what is displayed in the task manager, The extra 'Microsoft Excel - WorkbookName.xls' is displayed starting from step 3 for active workbook.
You can see that all the time only one excel process is running.

combo
 
Hi Ace

Don't know if this will help, but when ever I have problems like this I've found that an Excel session is still running. I declare
it as an application object then use that as the container for all the rest then reset at the end.

Code:
Set xlApp = CreateObject("Excel.Application")
.....
.....
Set xlApp = Nothing
Any use? It's cured 99% of my problems.

Simon

 
>Public Function WkBkTltBall() As Long
Dim ws As Worksheet, idx As Long, Shts As String, Tlt As Long, WB As Workbook

How does it go if you use;

Public Function WkBkTltBall() As Long
Dim ws As Object, idx As Long, Shts As String, Tlt As Long

1. The 'Dim ws As Worksheet' may be dragging in the hanging instance
2. The WB Object may be doing that too, in any case you do not appear to use it.
 
Here's the secnario requested by [blue]combo[/blue]:

[blue]Open New Instance[/blue]
Microsoft Excel - Book1

[blue]Open Ball3[/blue]
Microsoft Excel - Ball[purple]3[/purple].xls

[blue]Open Ball4[/blue]
Ball3.xls
Ball4.xls [green]'What causes this Guy?[/green]
Microsoft Excel - Ball[purple]4[/purple].xls

[blue]Activate Ball3[/blue]
Ball3.xls
Ball4.xls
Microsoft Excel - Ball[purple]3[/purple].xls

[blue]Close Ball3[/blue]
Ball4.xls
Microsoft Excel - Ball[purple]4[/purple].xls

[blue]Your Thoughts? . . .[/blue]


See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
To All . . .

Understand ... I'm not trying to get rid of the lingering task, I'm trying to understand why its there! After all, [blue]Task Manager[/blue] certainly thinks so. Since enerything works I can only believe its proper. I'm going to see what microsoft saids about this. I'll post back if I can get anything.

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top