Hi Guys,
I am struggling with how to always handle the 462 error successfully. I am operating on VDI and I try to open a file to read some details from there. My experience show that it will finally open the file after 2 or 3 attempts.
The code I've written for that goes like this and still sometimes fails letting the error to pop up. I'd appreciate if someone could do some corrections:
and here is some delay logic meant to wait for 10 seconds:
Regards,
Witek
I am struggling with how to always handle the 462 error successfully. I am operating on VDI and I try to open a file to read some details from there. My experience show that it will finally open the file after 2 or 3 attempts.
The code I've written for that goes like this and still sometimes fails letting the error to pop up. I'd appreciate if someone could do some corrections:
Code:
For k = 1 To 2
Set sourceWB = Workbooks.Open(strFile & "Looping stuff.xlsm")
On Error Resume Next
If Err.Number <> 0 Then
WasteTime (10)
Set sourceWB = Workbooks.Open(strFile & "Looping stuff.xlsm")
End If
On Error GoTo 0
Next k
and here is some delay logic meant to wait for 10 seconds:
Code:
Sub WasteTime(Finish As Long)
Dim NowTick As Long
Dim EndTick As Long
EndTick = GetTickCount + (Finish * 1000)
Do
NowTick = GetTickCount
DoEvents
Loop Until NowTick >= EndTick
End Sub
Regards,
Witek