Error checking help


Posted by Anis on March 13, 2000 6:54 AM

Hi I have this macro code for opening all the links and sub links in spreadsheet. I get errors when the one of the links is already open and macro tries to reopen it again. How can I include error checking code so that, if the link spreadsheet is opened once it will not try to open it again but continue with next link.

Private Sub Workbook_Open()
alinks = ActiveWorkbook.LinkSources
For i = 1 To UBound(alinks)
Workbooks.Open alinks(i), False
blinks = ActiveWorkbook.LinkSources
On Error Resume Next
For j = 1 To UBound(blinks)
Workbooks.Open blinks(j), False
Next
On Error GoTo 0
Next
ThisWorkbook.Activate
End Sub

Posted by Celia on March 13, 2000 7:23 AM


Anis (Guess Who!)
This looks somewhat familiar!
Try moving the error statement :-

Private Sub Workbook_Open()
alinks = ActiveWorkbook.LinkSources
On Error Resume Next
For i = 1 To UBound(alinks)
Workbooks.Open alinks(i), False
blinks = ActiveWorkbook.LinkSources
For j = 1 To UBound(blinks)
Workbooks.Open blinks(j), False
Next
On Error GoTo 0
Next
ThisWorkbook.Activate
End Sub

Celia

Posted by Celia on March 13, 2000 7:26 AM


Anis (Guess Who!)
This looks somewhat familiar!
Try moving the error statement :-

Private Sub Workbook_Open()
alinks = ActiveWorkbook.LinkSources
On Error Resume Next
For i = 1 To UBound(alinks)
Workbooks.Open alinks(i), False
blinks = ActiveWorkbook.LinkSources
For j = 1 To UBound(blinks)
Workbooks.Open blinks(j), False
Next
On Error GoTo 0
Next
ThisWorkbook.Activate
End Sub

Celia

AMENDMENT :-

SORRY - Probably also have to move "On Error GoTo " to after the second "Next"

Celia

Posted by Anis on March 13, 2000 8:19 AM

thanks celia. I'm wondering if there is any wwwboard like this board..if there is, could you give me the full url. thank you



Posted by Celia on March 13, 2000 8:34 AM

Re: thanks celia. I'm wondering if there is any wwwboard like this board..if there is, could you give me the full url. thank you

Anis
You might like to look at :-
http://peach.ease.lsoft.com/archives/excel-l.html

There are lots more. Check Excel sites for lists of Excel links. There is a ton of free information and help available – it’s just a question of looking for it.
Also, check the Microsoft website. I think they provide links to experts who provide free help and answers to questions.

Celia