The object invoked has disconnected from its clients.

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Does anyone know why I get the error

-2147417848: Automation error
The object invoked has disconnected from its clients.

on the line indicated in the snippet of code?

Code:
    strWorksheet = "tblComputerSystemInformation"
    strMotherBoardSerialNumber = MotherBoardSerialNumber()
    Set ws = ThisWorkbook.Sheets("tblLicences")
    
    If intLicences < 4 Then
        With ThisWorkbook.Sheets("tblLicences")
            For lngNewRow = 2 To 11
                If .Range("A" & lngNewRow) = "" Then
                    Exit For
                Else
                End If
            Next lngNewRow
            
            .Range("A" & lngNewRow) = strMotherBoardSerialNumber     'ERRORS HERE
            .Range("B" & lngNewRow) = GetBIOSSerialNumber()             
            .Range("C" & lngNewRow) = GetHardDiskSerialNumberHex1("C:\") 
            
            ThisWorkbook.Sheets(strWorksheet).Select
            
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Processor"
                .AutoFilter Field:=3, Criteria1:="ProcessorId"
            End With
        
            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("D" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'PROCESSOR SERIAL NUMBER, processorSerialNumber
            End With
                
            Selection.AutoFilter
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Did the code ever work?
What is behind MotherBoardSerialNumber()
How has strMotherBoardSerialNumber been dimmed (what type)?

If you move to next instruction (.Range("B" & lngNewRow) = GetBIOSSerialNumber()) does it work or not?

Bye
 
Upvote 0
Did the code ever work?
What is behind MotherBoardSerialNumber()
How has strMotherBoardSerialNumber been dimmed (what type)?

If you move to next instruction (.Range("B" & lngNewRow) = GetBIOSSerialNumber()) does it work or not?

Bye
Initially the code did work.
strMothherBoardSerialNumber is a string.
When it works then all three lines work.
 
Upvote 0
I think I have solved the issue. Before this code I was not using the correct code to turn off a filter. Rectifying this seems to have solved the issue.
 
Upvote 0
I think I have solved the issue. Before this code I was not using the correct code to turn off a filter. Rectifying this seems to have solved the issue.
Spoke too soon.

Here is the whole Sub. Note that "tblComputerSystemInformation" and "tblLicences" are Excel tables.

Code:
Public Sub UpdateLicence(intLicences As Integer)
     
    Dim lngNewRow As Long
    Dim strLicenceKey As String
    Dim strWorksheet As String
    Dim strMotherBoardSerialNumber As String
    Dim x As Integer
    Dim ws As Worksheet
 
    On Error GoTo ErrorHandler
 
    strWorksheet = "tblComputerSystemInformation"
    strMotherBoardSerialNumber = MotherBoardSerialNumber()
    Set ws = ThisWorkbook.Sheets("tblLicences")
 
    If intLicences < 4 Then
        With ThisWorkbook.Sheets("tblLicences")
            For lngNewRow = 2 To 11
                If .Range("A" & lngNewRow) = "" Then
                    Exit For
                Else
                End If
            Next lngNewRow
         
            .Range("A" & lngNewRow) = strMotherBoardSerialNumber         'MOTHER BOARD SERIAL NUMBER, MotherBoardSerialNumber 'AARAAR
            .Range("B" & lngNewRow) = GetBIOSSerialNumber()              'BIOS SERIAL NUMBER, BIOSserialnumber
            .Range("C" & lngNewRow) = GetHardDiskSerialNumberHex1("C:\") 'C DRIVE SERIAL NUMBER, CDriveSerialNumber
         
            ThisWorkbook.Sheets(strWorksheet).Select
         
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Processor"
                .AutoFilter Field:=3, Criteria1:="ProcessorId"
            End With
     
            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("D" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'PROCESSOR SERIAL NUMBER, processorSerialNumber
            End With
             
            Selection.AutoFilter
         
'            !Field5 = ELookup("[valuename]", "tblComputerSystemInformation", "[nametype]='IPAddress' AND [groupname]='Network' AND [MotherBoardSerialNumber]='" & MotherBoardSerialNumber() & "'") 'NETWORK IP ADDRESS, networkipaddress
'            !Field6 = GetMACAddress 'MAC ADDRESS, macaddress
'            !Field7 = Now() 'MAC ADDRESS DATE, macaddressdate
            .Range("H" & lngNewRow) = GetDriveCapacity("C:") 'C DRIVE CAPACITY, CDriveCapacity
'            !Field9 = GetDriveTypeValue("C:") 'C DRIVE TYPE, CDriveType
'            !Field10 = GetVolumeName("C:") 'C DRIVE VOLUME NAME, CDriveVolumeName
            .Range("K" & lngNewRow) = GetFileSystem("C:") 'C DRIVE FILE SYSTEM, CDriveFileSystem

            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Operating System"
                .AutoFilter Field:=3, Criteria1:="OSArchitecture"
            End With

            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("L" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'OS ARCHITECTURE, OSArchitecture or Windows 32|64 bit
            End With

            Selection.AutoFilter
         
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Processor"
                .AutoFilter Field:=3, Criteria1:="Name"
            End With

            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("M" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'PROCESSOR, processor
            End With
         
            Selection.AutoFilter
         
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Operating System"
                .AutoFilter Field:=3, Criteria1:="CSDVersion"
            End With

            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("N" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'SERVICE PACK, servicepack
            End With
         
            Selection.AutoFilter
         
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Onboard Devices"
                .AutoFilter Field:=3, Criteria1:="Description"
            End With

            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("O" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'GRAPHICS, graphics
            End With

            Selection.AutoFilter
         
            With ActiveSheet.ListObjects(strWorksheet).Range
                .AutoFilter Field:=1, Criteria1:=strMotherBoardSerialNumber
                .AutoFilter Field:=2, Criteria1:="Total RAM"
                .AutoFilter Field:=3, Criteria1:="Total RAM"
            End With

            With Worksheets(strWorksheet).AutoFilter.Range
                ws.Range("P" & lngNewRow) = Range("D" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Value2 'RANDOM ACCESS MEMORY, totalRAM
            End With

            .Range("Q" & lngNewRow) = Format(Val(Application.Version), "0.0") 'MS OFFICE VERSION, msofficeversion
'            !Field18 = RegistryKey("HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\UserName") 'USER NAME, UserName
'            !Field19 = RegistryKey("HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\UserInitials") 'USER, userinitials
            .Range("T" & lngNewRow) = FindandReplace1(GetOperatingSystem(), "  ", " ") 'OPERATING SYSTEM, OperatingSystem
            If IsMac = True Then
                .Range("U" & lngNewRow) = "MAC" 'MAC OR PC, macorpc
            Else
                .Range("U" & lngNewRow) = "PC" 'MAC OR PC, macorpc
            End If
            If Is64BitOffice = True Then
                .Range("V" & lngNewRow) = "MS Office 64 bit" 'MS OFFICE SYSTEM TYPE, msofficesystemtype
            Else
                .Range("V" & lngNewRow) = "MS Office 32 bit" 'MS OFFICE SYSTEM TYPE, msofficesystemtype
            End If
        End With
'        CurrentDb.Execute "UPDATE tblLicences SET tblLicences.FIELD23 = [Field1] & ' | ' & [Field2] & ' | ' & [Field3] & ' | ' & [Field4];"
    Else
        strMessage = "You have already reached the maximum limit of 3 machines upon which your chosen software product can can be used." & vbCrLf & vbCrLf & "Please review your existing licences and add\delete as necessary."
        With frmMessageBox3
            .lblMessage.Caption = strMessage
            .lblMessage.ForeColor = RGB(255, 0, 0)
            .show
        End With
    End If

ErrorHandler:
    If Err.Number <> 0 Then
        MsgBox Err.Number & ": " & Err.Description
'        Resume
    End If

End Sub
 
Upvote 0
How can we reproduce your problem??

Add these Debug.Print lines in this position:
VBA Code:
'previous code
            Next lngNewRow
Debug.Print ">>>"
Debug.Print "A", strMotherBoardSerialNumber
Debug.Print "B", GetBIOSSerialNumber()
Debug.Print "C", GetHardDiskSerialNumberHex1("C:\")

            .Range("A" & lngNewRow) = strMotherBoardSerialNumber         'MOTHER BOARD SERIAL NUMBER, MotherBoardSerialNumber 'AARAAR
            .Range("B" & lngNewRow) = GetBIOSSerialNumber()              'BIOS SERIAL NUMBER, BIOSserialnumber
            .Range("C" & lngNewRow) = GetHardDiskSerialNumberHex1("C:\") 'C DRIVE SERIAL NUMBER, CDriveSerialNumber
'further code
Then run the macro.
When you get the error and enter the Debug mode, open the vba "Immadiate Windows" (Contr-g should get you there; or Menu /View /Immediate Window)

Copy what you read in that window and paste it in your next message.

Bye
 
Upvote 0
How can we reproduce your problem??

Add these Debug.Print lines in this position:
VBA Code:
'previous code
            Next lngNewRow
Debug.Print ">>>"
Debug.Print "A", strMotherBoardSerialNumber
Debug.Print "B", GetBIOSSerialNumber()
Debug.Print "C", GetHardDiskSerialNumberHex1("C:\")

            .Range("A" & lngNewRow) = strMotherBoardSerialNumber         'MOTHER BOARD SERIAL NUMBER, MotherBoardSerialNumber 'AARAAR
            .Range("B" & lngNewRow) = GetBIOSSerialNumber()              'BIOS SERIAL NUMBER, BIOSserialnumber
            .Range("C" & lngNewRow) = GetHardDiskSerialNumberHex1("C:\") 'C DRIVE SERIAL NUMBER, CDriveSerialNumber
'further code
Then run the macro.
When you get the error and enter the Debug mode, open the vba "Immadiate Windows" (Contr-g should get you there; or Menu /View /Immediate Window)

Copy what you read in that window and paste it in your next message.

Bye
Unfortunately I get the Restarting Excel before I am able to check what the error message is. I just about managed it last time.

A 123490EN400015
B HN0293FBC00452
C 4C958C5B

It will work OK for a few runs then I get the issue.
 
Upvote 0
Unfortunately I get the Restarting Excel before I am able to check what the error message is. I just about managed it last time.

A 123490EN400015
B HN0293FBC00452
C 4C958C5B

It will work OK for a few runs then I get the issue.
I have been having memory problems when I get a dialog box telling me that my memory is low.
I also halted the code to manually place the mother board serial number and I get the restarting excel dialog box again.
 
Upvote 0
The debug information are to be read when you enter debug mode, not when the macro runs ok.

Anyway I suspect that the problem lays in the things that are not shown here:
-the line strMotherBoardSerialNumber = MotherBoardSerialNumber() where and how fetches the board serial number?
-how does the statement GetBIOSSerialNumber() work?
-same question about = GetHardDiskSerialNumberHex1("C:\")

Probably you have installed an add-in that make available those commands, but that is beyond our investigation possibility

Sorry, I am unable to help; hope someone else cold enter the discussion...
 
Upvote 0
The debug information are to be read when you enter debug mode, not when the macro runs ok.

Anyway I suspect that the problem lays in the things that are not shown here:
-the line strMotherBoardSerialNumber = MotherBoardSerialNumber() where and how fetches the board serial number?
-how does the statement GetBIOSSerialNumber() work?
-same question about = GetHardDiskSerialNumberHex1("C:\")

Probably you have installed an add-in that make available those commands, but that is beyond our investigation possibility

Sorry, I am unable to help; hope someone else cold enter the discussion...
I did add the addin called PowerQuery which I don't know how to get rid of as I don't require it anymore.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top