Excel VBA“自动化错误:调用的对象与客户端已断开连接”

我想出了Nick的build议,下面是我得到的错误号码和描述:

'-2147417848(80010108)'自动化错误被调用的对象与客户端断开连接

我debugging时突出显示的代码行是:

.Lows(Lst).Insert Shift:= xlDown

我以为我曾经在这个或者另一个论坛上的某个地方取消注册,然后重新注册一个特定的文件,但是当我遇到这个问题的时候,我在家里,而不想在我的笔记本电脑上试用它,因为一切正常。 % 在上面。

再次,任何帮助,不胜感激。 我星期天离开两个星期,在离开之前我真的需要做这个工作。 大多数为我工作的人不是excel guru的,并且需要所有的button/function,因为他们无法排除故障和/或解决问题。

我仍然坐在一个常规模块中的下面的代码,下面的一组代码是在一个工作表模块。

Sub add_InvRow() Application.Calculation = xlCalculationManual Application.EnableEvents = False switch = "off" With ThisWorkbook Dim wb As Excel.Workbook, Lst As Long Set wb = Application.ThisWorkbook Dim ws As Worksheet, sw As Worksheet, os As Worksheet Set ws = ActiveSheet: Set sw = Application.Sheets(Sheet1.Name): Set os = Application.Sheets(Sheet4.Name) With ws Lst = ActiveCell.Row End With If ws.CodeName = "Sheet3" Then With os .Rows(213).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False venTabForm.Show End With End If If ws.CodeName = "Sheet23" Then With sw .Rows(135).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False cItemForm.Show End With End If If ws.CodeName = "Sheet25" Then With sw .Rows(105).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False coInvForm.Show End With End If If ws.CodeName = "Sheet28" Then With sw .Rows(100).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False kInvForm.Show End With End If If ws.CodeName = "Sheet27" Then With sw .Rows(130).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False ItemForm.Show End With End If If ws.CodeName = "Sheet22" Then With sw .Rows(120).Copy End With With ws .Rows(Lst).Insert Shift:=xlDown Application.CutCopyMode = False caInvForm.Show End With End If Set ws = Nothing: Set sw = Nothing: Set os = Nothing: Set wb = Nothing End With switch = "on" Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic End Sub 

此代码位于具有调用上述代码的命令button的工作表之一中。

  Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If switch = "off" Then Exit Sub If Target.Address = "$H$1" Then Call findItem Exit Sub End If If Application.Intersect(Target, Me.Range("P:P")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub If Target.Cells.Value = 0 Or Target.Cells.Value = "" Then Exit Sub Dim wb As Workbook, ws As Worksheet, iNUM As String, kitSHT As Worksheet, ksRNG As Range, kITEM As Range, kbCELL As Range Dim iNAME As String, catSHT As Worksheet, csRNG As Range, cbCELL As Range, cITEM As Range Dim logCELL As Range Set wb = ThisWorkbook: Set ws = wb.Sheets(Sheet27.Name): Set kitSHT = wb.Sheets(Sheet28.Name): Set catSHT = wb.Sheets(Sheet22.Name) Set ksRNG = kitSHT.Range("C5:C1100"): Set kbCELL = ksRNG.Cells(5, 3) Set csRNG = catSHT.Range("C6:C400"): Set cbCELL = csRNG.Cells(6, 3) If (Not (Application.Intersect(Target, Me.Range("A:P")) Is Nothing)) And (Target.Cells.Count = 1) And (Target.Column = 16) Then If Target.Value = 0 Then Exit Sub iNUM = Target.Offset(, -12).Value iNAME = Target.Offset(, -10).Value If kitSHT.Cells.Find(What:=iNUM, After:=kbCELL, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) Is Nothing And _ catSHT.Cells.Find(What:=iNUM, After:=cbCELL, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) Is Nothing Then MsgBox iNUM & "-" & iNAME & "" & " is not currently listed on" & " " & kitSHT.Name & " " & "or" & " " & catSHT.Name & vbNewLine & vbNewLine & _ "Please add" & " " & iNUM & "-" & iNAME & "" & " to" & " " & kitSHT.Name & " " & _ "or" & " " & catSHT.Name & " " & "and corresponding count sheets", vbInformation Set wb = Nothing: Set ws = Nothing: Set kbCELL = Nothing Set ksRNG = Nothing: Set kitSHT = Nothing: Set cbCELL = Nothing: Set catSHT = Nothing: Set csRNG = Nothing Exit Sub Else If Target.Value = 0 Then Exit Sub premNUM = iNUM pFORM.Show End If End If Set wb = Nothing: Set ws = Nothing: Set kbCELL = Nothing Set ksRNG = Nothing: Set kitSHT = Nothing: Set cbCELL = Nothing: Set catSHT = Nothing: Set csRNG = Nothing Set ksRNG = Nothing: Set kitSHT = Nothing: Set cbCELL = Nothing: Set catSHT = Nothing: Set csRNG = Nothing End Sub 

好吧…已经过了1个多月了,我终于修好了! 幸运的是,不幸的是,这与我的代码完全没有关系。 相反,这是一个MS Office Vs. Windows 8的问题。 为了解决这个问题,我运行了兼容性问题排查工具,并且一切又恢复了完美:

  1. 打开MS Excel(任何文件或新文件)
  2. 拉起任务pipe理器
  3. 单击后台进程中的MS Office或Excel图标,右键单击并select属性
  4. 在“兼容性”下,单击“运行兼容性疑难解答”
  5. 完成运行后,再次testing文件,如果正常工作,点击应用设置到这个程序。 如果不起作用,请单击下一步并从选项中进行select。 (我select它在以前版本的Windows(Windows 7)中工作然后再次单击下一步。
  6. 再次testing文件,它工作。

我不能相信这是我一直以来的事情! 我实际上花了149美元,认为微软支持可以远程和修复它,但这是一个绝对的浪费! 我被转移到了12个以上的不同的人员/部门,而他们却一无所获。 我今天早上终于偶然发现了这个解决scheme….

无论如何,感谢所有贴出来并试图帮助我的人。 我总是以更好的VBA技能login这个网站,而不是因为我们所有人的login…所以再次感谢!

我已经使用了Excel 2007而不是2010,并且一切工作都很完美,不需要更改一行代码!