I have a macro running on a PC that is locked. A VB script calls the VBA every 5 minutes or so. The majority of the time there is no problem. However every few days it will throw the error 52.
I have marked below where the error is. When I log into the pc and hit debug and play it runs fine i.e. there is no issue with the file names and path. Has anyone experienced this? The error only occurs when the machine is locked, but even then the error might not happen for a day or so. This is not the full code but it includes everything up until the point of error, the rest of the code manipulates the files after opening and works just fine.
Public Sub OpenFilesInFolder() 'DECLARE AND SET VARIABLES Dim wbk As Workbook Dim Filename As String Dim Path As String 'ERROR GETS THROWN HERE Path = "\\rootdirectory\filesIn\" Filename = Dir(Path & "*.*") Do While Len(Filename) > 0 'IF NEXT FILE EXISTS THEN Set wbk = Workbooks.Open(Path & Filename) Filename = ActiveWorkbook.Name Windows(Filename).Close End Sub