VB中EXCEL进程没办法关闭

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As Single)
Dim NUM As Integer, BE As String, MM As String
If LCase(Right(Data.Files(1), 4)) = ".xls" Then ''判别是否为EXCEL文件
MM = Right(Data.Files(1), 4)
Text1.Text = Data.Files(1) ''获取EXCEL文件路径
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(Text1.Text)
Set xlSheet = xlBook.Worksheets(1)
xlApp.Range(Cells(6, 6), Cells(6, 7)).HorizontalAlignment = xlCenter '母件单位及数量水平居中

If Dir(Replace(Text1.Text, MM, "1.xls")) <> "" Then
If MsgBox("文档已存在,是否替代此文档!", vbYesNo, "注意") = vbYes Then
Kill (Replace(Text1.Text, MM, "1.xls"))
Else
xlApp.DisplayAlerts = False
GoTo QU
Exit Sub
End If
End If
''******************************另存***********************************
Text1.Text = Replace(Text1.Text, MM, "1.xls")
xlApp.ActiveWorkbook.SaveAs (Text1.Text)
GoTo QU
Else
MsgBox "非EXCEL文件!", vbOKOnly, "注意"
End If
Exit Sub
QU: ''******************************退出***********************************
Me.Caption = "请将K3导出BOM拖到窗体中"
xlApp.ActiveWorkbook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
End Sub

xlApp.ActiveWorkbook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
这段应该就是已经把进程关闭了追问

进程中还在!

追答

那就用API关掉它

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-04-26
如果关闭时出理提示用这个。xlApp.DisplayAlerts = False追问

关键是没提示,这个之前也试过!关不了!

追答

你是在VB6还是VB.Net中找开Excel文件吗?是不是进程中还有?你可以将程序自动关闭看进程中还有没有。

相似回答
大家正在搜