dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,352
- Office Version
- 365
- 2016
- Platform
- Windows
I have a procedure that copies rows of a table to other worksheets that works fine most of the time. Sometimes I think it becomes corrupted or something similar as I get the error of method of open worksheets failed and it highlights the code to open the file. All I need to do is open the workbook manually, select save as and replace the file you opened and then it seems to stop giving me the error. Is there a way to build into the code that if that error occurs, it will complete the above solution automatically, without having to open the workbook manually? This is the code that opens the workbooks. When there is a problem with the workbook to be opened, the last half of the line to open the workbook will be highlighted.
VBA Code:
If Not isFileOpen(DocYearName & ".xlsm") Then Workbooks.Open ThisWorkbook.Path & "\" & "Work Allocation Sheets" & "\" & Site & "\" & DocYearName & ".xlsm"
If Not isFileOpen(HoursRegister & ".xlsm") Then Workbooks.Open ThisWorkbook.Path & "\" & "Hours Register" & "\" & Site & "\" & HoursRegister & ".xlsm"
If Not isFileOpen(ReportTracking & ".xlsm") Then Workbooks.Open ThisWorkbook.Path & "\" & "Report Tracking" & "\" & Site & "\" & ReportTracking & ".xlsm"