gpt4 book ai didi

excel - "Automation Error: Object Invoked has disconnected from its clients"

转载 作者:行者123 更新时间:2023-12-02 10:10:20 24 4
gpt4 key购买 nike

我明白了 Nick 的建议,以下是我收到的错误号和描述:

'-2147417848 (80010108)' Automation error The object invoked hasdisconnected from its clients

调试时突出显示的代码行是:

.Rows(Lst).Insert Shift:=xlDown

我以为我在这个或另一个论坛上的某个地方看到了取消注册然后重新注册特定文件的方法,但是当我遇到这个问题时我正在家里,并且不想在我的笔记本电脑上尝试它,因为一切已经 100% 工作了。

再次感谢您的帮助。我周日要休假两周,我真的需要在离开之前把这个工作做好。大多数为我工作的人都不是 excel 专家,需要所有按钮/功能正常工作,因为他们无法排除故障和/或解决问题。

我仍然在常规模块中使用以下代码,下面的下一组代码位于其中一个工作表模块中。

 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


此代码位于具有命令按钮的工作表之一上,该按钮调用上述代码。

 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 与 Office 的较量。 Windows 8 问题。为了解决这个问题,我运行了兼容性疑难解答,一切又恢复完美:

  1. 打开 MS Excel(任何文件或新文件)
  2. 调出任务管理器
  3. 单击后台进程中的 MS Office 或 Excel 图标,右键单击,然后选择属性
  4. 在“兼容性”下,点击“运行兼容性问题排查程序”
  5. 运行完成后,再次测试文件,如果工作正常,请单击“将设置应用于此程序”。如果不起作用,请单击“下一步”并从选项中进行选择。 (我选择它在以前版本的 Windows (Windows 7) 中有效,然后再次单击“下一步”。
  6. 再次测试文件,结果成功了。

我不敢相信这就是我一直以来要做的一切!实际上,我花了 149 美元以为 Microsoft 支持可以远程访问并修复它,但这绝对是浪费!我被调到 12 多个不同的人/部门,但仍然没有从他们那里得到任何东西。今天早上我终于偶然发现了解决方案......

无论如何,感谢所有发帖并试图帮助我的人。由于你们所有人,我总是以比登录时更好的 VBA 技能注销此网站...所以再次感谢!

关于excel - "Automation Error: Object Invoked has disconnected from its clients",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34246264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com