for example, there are several places in my code where I access the Excel file. It can happen that the file is open by another process or is missing (someone delete it). I want to test during each access these situations.
My code should look like:
- Set required variables
- While (error or max attempts condition)
- — Try
- — --- Excel process block ← [Just this will change]
- — Case
- — --- If (file exists)
- — --- — Alert - cannot be opened
- — --- Else
- — --- — Alert - does not exist
My idea is that everything but the Excel process block would be always the same. The Excel process block would be once Read Range, once Write Range and so on.
How can I do it to don’t have to copy and paste all this code and always cover the main one small working block by that ugly cover?