A family of Microsoft relational database management systems designed for ease of use.
You'll also need to do some error handling.
Public Function RefreshExcel()On Error Goto ErrorHandler '>>> place this here'''End WithErrorExit:On Error Resume NextSet appexcel = Nothing '>>>Close/Destroy the object so that it does not stay active/hiddenExit FunctionErrorHandler:If Err.Number <> 0 thenMsgBox "Error: " & Err.Number & " - " & Err.Description , vbCritical, "RefreshExcel"End IfResume ErrorExit 'Exit Function gracefully to kill the Excel App/ObjectEnd Function
In the VBA Editor, go to Tools - Options - General Tab - Error Trapping - set to "Break on UnHandled Errors".