How to test success of a "Set" command?
2003/2007
There is a probable a better way. The GoToWb opens at the '******* line of code. If the file
has not opened by '$$$$$$$$$ line then I have the code line - If Err.Number 0 Then
Workbooks(GoToWb).Activate If Err.Number 0 Then
On Error GoTo 0
On Error Resume Next
Set Windows(GoToWb) = Workbooks(GoToWb)
On Error GoTo 0
On Error Resume Next
Set Workbooks(GoToWb) = Workbooks.Open(Filename:=GoToPath & GoToWb) '*******
On Error GoTo 0
On Error Resume Next
Set Workbooks(GoToWb) = Workbooks.Open(Filename:=Application.DefaultFilePa th & _
"\" & GoToWb) '$$$$$$$$$
If Err.Number 0 Then
.......
Endif
Endif
Since the file opens at '******* then the Set command at '$$$$$$$$$ produces an error when
the file is already open.
How do I test the success of the previous Set command so that I do not produce an error?
|