Closing Excel process (1 Viewer)

Kiwiman

Registered User
Local time
Today, 21:30
Joined
Apr 27, 2008
Messages
799
Howzit

This works fine with me. I only have the one excel process (the one I had initially) running after the task completes.

I was also going to mention that you should try and avoid using Mapped Drives and use instead the full UNC path so you get by any requirement that all users (should other users use this facility) do not have to have the same path mapped to the same Drive letter.
 

KirkComer

Registered User.
Local time
Today, 16:30
Joined
Oct 21, 2005
Messages
50
It has to be something to do with those microsoft updates I recently received on my computer. I'm at a loss on this one. Maybe microsoft will make a update to fix my update. lol
 

Kiwiman

Registered User
Local time
Today, 21:30
Joined
Apr 27, 2008
Messages
799
Howzit

You have

Code:
MySheetPath = "T:\Database\DPC\Completed DPC Forecast.xlsx"

where the T Drive could be mapped to "\\yourserver". If you use a mapped drive you are reliant on everyone having the same mapping whereas in reality they may have the T drive mapped to "\\yourotherserver" or "\\yourserver\yourfolder", which is different to your own and will therefore likely fail as the path would not be found.

I would use the entire UNC File path and have

Code:
MySheetPath = "\\yourserver\Database\DPC\Completed DPC Forecast.xlsx
 

KirkComer

Registered User.
Local time
Today, 16:30
Joined
Oct 21, 2005
Messages
50
Just wanted to let everyone know that I believe I have figured out the cause of the EXCEL.EXE processes not closing in task manager. I had one computer that was working correctly. I did the microsoft update for Windows Live and immediately the same problem started happening. I then uninstalled Windows Live from both computers but I've still got the same problem. It's frustrating. If anyone ever stumbles upon a solution for this please let me know.

Kiwiman,
Do you think your bandaid fix would help with my situation?
 

vbaInet

AWF VIP
Local time
Today, 21:30
Joined
Jan 22, 2010
Messages
26,374
Alright Kirk, I've made some changes to your code. Kill all instances of Excel, open the db and run the code (by the clicking the button). Don't add or change anything - well you can change the file path to a local path, i.e. a file on your home drive or desktop. Remember to Debug > Compile if you do.

See if the instance still lingers.
 

Attachments

  • Copy of COMNauto.mdb
    284 KB · Views: 97

Minty

AWF VIP
Local time
Today, 21:30
Joined
Jul 26, 2013
Messages
10,371
I know this is a bit of a thread resurrection but can anyone see why I would be getting an orphaned Excel process left behind using this code;
PHP:
Private Sub FormatExportSheet(sFilename As String, sWrkSht As String)

    Dim sFile            As String
    Dim objXL            As Excel.Application
    Dim NumberOfRows     As Integer
    Dim MyRange          As String

    On Error GoTo FormatExportSheet_Error

    sFile = sFilename & ".xlsx"

    Set objXL = New Excel.Application
    objXL.Workbooks.Open (sFile)

    NumberOfRows = objXL.Sheets(sWrkSht).UsedRange.Rows.Count

    MyRange = "N2:N" & NumberOfRows - 1

    With objXL
        .Worksheets(sWrkSht).Activate
        .Worksheets(sWrkSht).Rows("1:1").Font.Bold = True
        .Columns("A:N").Autofit
        .Range(MyRange).Select
        With objXL.Selection.Font
            .Name = "ABC C39 Short Text"
            .Size = 16

        End With
        MyRange = "A1:N" & NumberOfRows
        .ActiveSheet.ListObjects.Add(xlSrcRange, Range(MyRange), , xlYes).Name = "Table1"
        .Range("A1").Select
        .ActiveWorkbook.Close True
        .Quit
    End With

    Set objXL = Nothing

    On Error GoTo 0
    Exit Sub

FormatExportSheet_Error:
  
    Set objXL = Nothing
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure FormatExportSheet of ModCustomerImports"

End Sub

I am A) puzzled as I'm sure I've used similar code before without issue and
B) with the orphaned process running the code fails on the table formatting line every time... which is not pleasing and a right royal pain the butt.

I can't get the table formatting to work using late binding either.
 

JHB

Have been here a while
Local time
Today, 22:30
Joined
Jun 17, 2012
Messages
7,732
You're missing the Excel reference for the Range in this line, (I put in the . and marked it with red).
Code:
[COLOR=#000000][COLOR=#007700].[/COLOR][COLOR=#0000BB]ActiveSheet[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]ListObjects[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]xlSrcRange[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB][COLOR=Red][B].[/B][/COLOR]Range[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]MyRange[/COLOR][COLOR=#007700]), , [/COLOR][COLOR=#0000BB]xlYes[/COLOR][COLOR=#007700]).[/COLOR][COLOR=#0000BB]Name [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"Table1" 
[/COLOR][/COLOR]
I don't think it make a problem, but why do you have:
Code:
[COLOR=#000000][COLOR=#0000BB][COLOR=#000000][COLOR=#0000BB]    With objXL 
        [/COLOR][/COLOR][/COLOR][/COLOR][COLOR=#000000][COLOR=#0000BB][COLOR=#000000][COLOR=#0000BB][COLOR=#000000][COLOR=#0000BB][COLOR=#000000][COLOR=#007700]...
[/COLOR][/COLOR][/COLOR][/COLOR]        [/COLOR][COLOR=#007700]...[/COLOR][COLOR=#0000BB]
        With [B][COLOR=Red]objXL[/COLOR][/B][/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Selection[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Font 
            [/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Name [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"ABC C39 Short Text" 
            [/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]Size [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]16 

        End With 
[/COLOR][/COLOR][/COLOR][COLOR=#0000BB] 
[/COLOR][/COLOR]
 

Minty

AWF VIP
Local time
Today, 21:30
Joined
Jul 26, 2013
Messages
10,371
Thanks JHB , between those two things it's cured.
I suspect the .Range thing was a typo introduced by me fiddling with the references, from late to early binding.

The second objXL one is just plain thickness, no excuses.
 

Users who are viewing this thread

Top Bottom