To fix "Run-time error '4198': Command failed" in macro to open hyperlinks
This little macro opens selected URLs in a Word document.... until it hits a dead link.
Then it reports "Run-time error '4198': Command failed" and stops.
Please could you tell me how to amend the code so that dead links are skipped, and the macro continues to open remaining valid links.
(I do not need the act of skipping to be reported or approved. It's acceptable simply to ignore dead links).
Many thanks
Code:
Sub OpenLinks()
Dim alink As Hyperlink
For Each alink In Selection.Hyperlinks
alink.Follow '<<<<<<<<<<<<<<<<<<<<<<Run-time error '4198': Command failed
Next alink
End Sub
1 Attachment(s)
"Compile error: External name not defined"
Thanks, Logit, for a creative workaround but I'm getting this error. Please help.
Attachment 18604
Quote:
Originally Posted by
Logit
Try this :
Code:
Sub OpenLinks()
On Error Resume Next '<---- add this line
Dim alink As Hyperlink
For Each alink In Selection.Hyperlinks
alink.Follow '<<<<<<<<<<<<<<<<<<<<<<Run-time error '4198': Command failed
Next alink
End Sub
It's not a recommended method in coding but you stated skipping doesn't need to be approved or corrected.