1) I am working on a rather complex macro, and occassionaly make a little
mistake. Unfortunately, being that I am looping through my document, this
often leads to an infinite loop. How can I stop the macro, without closing
Word (which results in me losing my changes to the macro).
2) Is there a way in macro code to recogize that I am on a line of text that
has a hyperlink in it, and to access the hyperlink detail?
Jonathan West - 06 Feb 2006 16:06 GMT
> 1) I am working on a rather complex macro, and occassionaly make a little
> mistake. Unfortunately, being that I am looping through my document, this
> often leads to an infinite loop. How can I stop the macro, without closing
> Word (which results in me losing my changes to the macro).
Press Ctrl-Break to stop the macro.
> 2) Is there a way in macro code to recogize that I am on a line of text
> that
> has a hyperlink in it, and to access the hyperlink detail?
Dim oLink as Hyperlink
If Selection.Paragraphs(1).Range.Hyperlinks.Count > 0 Then
Set oLink = Selection.Paragraphs(1).Range.Hyperlinks(1)
'Do whatever you want with the link here
End If

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Helmut Weber - 06 Feb 2006 16:30 GMT
Hi Dan,
[ctrl break] plus
Application.EnableCancelKey = wdCancelInterrupt
just in case it was set to wdCancelDisabled.
But I always forget about that.
So I use a counter that stops the program
if the value of the counter gets too high.
With Selection.Bookmarks("\line").Range
If .Hyperlinks.Count > 0 Then
MsgBox "hyperlink"
MsgBox .Hyperlinks(1).Address
' I am not quite sure here
End If
End With

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Dan Perkins - 06 Feb 2006 21:27 GMT
Jonathan and Helmut, thank you both for your help, I appreciate it very much.
> Hi Dan,
>
[quoted text clipped - 15 lines]
> End If
> End With