Hello everyone

I have a shared excel file that serves as a department database, and it has a userform that allows users to search staff details and create new password. Also, the userform allows the admin team to edit, add, or delete staff details in the database using an admin password.

This file is working well on my laptop. However, when I started using this in a network shared drive, it started giving this Automation Error in several functions. At first, it appeared when closing the userform that triggers the Activeworkbook.Close command. Then, after I changed it to Thisworkbook.Close, the Automation Error went on to searching a staff details, and even on ActiveWindow.DisplayHorizontalScrollBar. But what's driving me crazy is that after I specified the particular workbook & worksheet for each range or cell commands I used, the Automation Error still occur and it's an intermittent thing.

Can someone please,please try to explain why this is happening? Is this a code or network error, or excel sharing conflict, or an excel bug?

Since the error appeared almost everywhere on my code, I just pasted a sample code I already revised yet with intermittent error when executed.

Private Sub CommandButton18_Click() 'Search in ADD/DELETE PAGE
    Dim SearchID As String
    Dim FoundRange As Range
    Dim bottomA As Integer
    Dim ws As Worksheet
  
    Application.ScreenUpdating = False
    SearchID = TextBox24.Text
    
    With ws   Error still sometimes occur here
        Set ws = ThisWorkbook.Worksheets("Staff Details")
        Set FoundRange = ws.Cells.Find(what:=SearchID, LookIn:=xlValues, _
        lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)

        bottomA = ws.Range("A" & ws.Rows.Count).End(xlUp).Row   or here

        If FoundRange Is Nothing Then
        MsgBox "SAP ID not found. Please try again or contact administrator.", vbOKOnly
        TextBox1.Text = Empty
    Else
        TextBox21.Value = FoundRange.Offset(0, 1).Value 'Name
        TextBox20.Value = FoundRange.Offset(0, 2).Value 'Position
        TextBox22.Value = FoundRange.Offset(0, 3).Value 'Station
        TextBox23.Value = FoundRange.Offset(0, 4).Value 'Line Manager
    End If
    End With
    Application.ScreenUpdating = True
End Sub
Thank you so much for all your time to help.

hydz1213