Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Questions: Infinite Loops, Hyperlinks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Perkins - 06 Feb 2006 15:57 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).

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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.