在Access进程中退出excel后,在任务管理器中显示stil,直到完全退出访问

时间:2016-07-08 14:21:08

标签: excel vba ms-access taskmanager

我在退出后在任务管理器进程中显示excel的问题。我已经搜索了许多不同的答案,仍然在任务管理器中显示进程。我在其他函数中有其他vba代码打开和关闭excel就好并从进程中删除,但是我在下面运行的当前事件只是将进程留在任务管理器中,直到我完全退出访问。请帮助!!

 Private Sub status_ID_AfterUpdate()
 On Error GoTo Problems
 Dim filename As String
 Dim NewStatus As Long

 filename = "M:\Shared Documents\Job Cost Analysis\Hospital Active B2B Cases.xlsx" 

 Dim cell As Range
 Dim xlApp As Excel.Application
 Dim xlWB As Excel.Workbook
 Dim ws As Worksheet

 Set xlApp = New Excel.Application
 With xlApp
    .Visible = True
    Set xlWB = .Workbooks.Open(filename, , False)
    Set ws = .Worksheets("Active B2B cases")

ws.Columns("B:B").Select
Set cell = Selection.Find(What:=Me.client_ID.Value, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)

If cell Is Nothing Then
'do nothing
Else
'Update active B2B sheet

If Me.status_ID.column(0) = "FINAL PROCESSING" Then
ws.Range("E" & (xlApp.cell.Row)).Value = "Final Processing"
MsgBox "The client's status has been updated on the Active B2B sheet"
ElseIf Me.status_ID.column(0) = "DATA ENTRY" Then
ws.Range("E" & (xlApp.cell.Row)).Value = "Data Entry"
MsgBox "The client's status has been updated on the Active B2B sheet"
ElseIf Me.status_ID.column(0) = "COMPLIANCE REVIEW" Then
ws.Range("E" & (xlApp.cell.Row)).Value = "Available To Audit"
MsgBox "The client's status has been updated on the Active B2B sheet"
ElseIf Me.status_ID.column(0) = "SENIOR COMPLIANCE REVIEW" Then
ws.Range("E" & (xlApp.cell.Row)).Value = "2nd Level Review"
MsgBox "The client's status has been updated on the Active B2B sheet"
ElseIf Me.status_ID.column(0) = "WAITING FOR DOCUMENTATION" Then
ws.Range("E" & (xlApp.cell.Row)).Value = "Pending - Doc"
MsgBox "The client's status has been updated on the Active B2B sheet"
ElseIf Me.status_ID.column(0) = "INVOICED" Then
xlApp.cell.EntireRow.Delete
MsgBox "The client has been removed from the Active B2B sheet"
End If

End If

End With
xlApp.DisplayAlerts = False
xlWB.SaveAs (filename)
xlWB.Close
xlApp.Quit

Set cell = Nothing
DoEvents
Set ws = Nothing
DoEvents
Set xlWB = Nothing
DoEvents
Set xlApp = Nothing
DoEvents
Exit Sub

Problems:
Err.Clear

Resume Next
End Sub

1 个答案:

答案 0 :(得分:0)

至少在出现更好的解决方案之前,您可以将其添加到代码的末尾(在将变量设置为Nothing之后)。注意:这将终止计算机上的所有Excel实例。

height