I have a long piece of code (not worth posting in full) that loops through a folder of excels and performs 7 different procedures on them. The issue is that a given workbook will sometimes encounter issues (usually related to the internal structure or size of the workbook) which can cause the main module to error out. I was hoping to run a timer at the outset of the loop that once a certain time elapsed (say 2 minutes) it would move the excel to an error folder.
I think it would look something like this but I am not sure how to use the procedure call of the Application.OnTime method
I think it would look something like this but I am not sure how to use the procedure call of the Application.OnTime method
Code:
myFile = Dir(inProcessingPath & myExtension)
Do While myFile <> ""
ErrorTime = Now() + TimeValue("00:02:30")
Application.OnTime ErrorTime, 'Do something here I don't understand
Set Wb = Workbooks.Open(fileName:=myPath & myFile, UpdateLinks:=False, Editable:=True)
'here is where the 7 procedures are run
'Save and Close Workbook
Wb.Save
Set FSo = CreateObject("scripting.filesystemobject")
FSo.MoveFile source:=Wb.path, Destination:=newPath
'But if timer elapase newPath = path to an error Folder
'Get next file name
myFile = Dir
Loop