The following code edits multiple excel workbooks however before editing the workbooks it first checks to see if the workbook is in read/write mode. If it isn’t then it will close and open the workbook till read/write is active.
My concern is that this loop will continue forever if I don’t incorporate some sort of escape option to the next workbook.
Is there a way of implementing a simple dialog box with a 'Retry’ and ’Skip’ button if the loop reaches a certain number attempts e.g 5
Retry – Reattempt loop
Skip - Skip to the next workbook
For Each i In MyArray
xl.Workbooks.Open (i)
'If workbook in read only mode , close and open till read/write is active
Do Until xl.ActiveWorkbook.ReadOnly = False
xl.ActiveWorkbook.Close (False)
If GetAttr(i) = vbReadOnly Then _
SetAttr i, vbNormal
xl.Workbooks.Open (i)
If xl.ActiveWorkbook.ReadOnly = False Then Exit Do
Loop 'Loop above till read/write active
'''''More code here when workbook read/write mode
Next