Unfollow a Hyperlink color

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Unfollow a Hyperlink color

Post by Sundog »

In Word 2007, there are times when I test a hyperlink by clicking it. Word obligingly turns its color Violet, for a Followed Hyperlink. How can I tell Word (that hyperlink) that you are no longer followed, and please turn back to Blue?

If I change the Followed Hyperlink style color to Blue, that hyperlink turns back to Blue. But I really want a Followed Hyperlink to be Violet. So I change the Followed Hyperlink color back to Violet, and Word somehow remembers that that particular hyperlink was followed, and turns it back to Violet.

How do I Unfollow a hyperlink?
Sundog

User avatar
HansV
Administrator
Posts: 78489
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unfollow a Hyperlink color

Post by HansV »

Try clearing your browser history.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

HansV wrote:Try clearing your browser history.
Hans, I don't quite understand how this applies. I'm in Word, not in a browser. All my hyperlinks are internal to the same Word document. Sorry if I didn't make that clear initially.
Sundog

User avatar
HansV
Administrator
Posts: 78489
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unfollow a Hyperlink color

Post by HansV »

Ah! Try closing and reopening the document.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

That worked, thanks. That's a nuisance for large documents or if in the middle of a correction :groan: ; no other snazzy VBA :compute: way?
Sundog

User avatar
HansV
Administrator
Posts: 78489
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unfollow a Hyperlink color

Post by HansV »

I don't think there is another way to restore a hyperlink to its pristine state, but why would it be important to do so while editing a document?
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

If I am in the middle of a correction that is in my mind but not yet down on paper/entered into the document, need I wait to stop my brain churning, Save the document, Close the document, Open the document, find where in this large document I was, re-engage my brain, and put my fingers back to work?
Sundog

User avatar
HansV
Administrator
Posts: 78489
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unfollow a Hyperlink color

Post by HansV »

Sorry, that's not what I meant. I don't quite understand why it would be essential to "unfollow" a hyperlink while you are busy editing the document. The hyperlink will act the same whether its state is "followed" or not.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

It offends the eye and raises questions, if I'm sharing my editing session with an onlooker.

I'll explain that the color will change automagically upon closing and reopening the doc.
Sundog

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Unfollow a Hyperlink color

Post by Don Wells »

Sundog wrote: How do I Unfollow a hyperlink?
    The following code will unfollow a link to the web. I leave it to you to expand the macro to other types of hyperlink. Call back if further assistance is required. The macro processes the first hyperlink in the selected range. I have tested this in 2003 and expect that it will work in 2007. Please let us know how it works out.

Code: Select all

See following post.
Last edited by Don Wells on 19 Oct 2010, 15:33, edited 1 time in total.
Regards
Don

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Unfollow a Hyperlink color

Post by Don Wells »

Don Wells wrote:
Sundog wrote: How do I Unfollow a hyperlink?
    The following code upgrades that from my previous post to unfollow links internal to the host document.

Code: Select all

Option Explicit
Sub ResetLink()
Dim lngType As Long

  lngType = Selection.Hyperlinks(1).Type
  
  Select Case lngType
  Case 0
    Call ResetWebLink
  End Select
  
End Sub
Private Sub ResetWebLink()
Dim varAddress As Variant
Dim varSubAddress As Variant
Dim varLabel As String

  With Selection
    With .Hyperlinks(1)
      .Range.Select
      varAddress = .Address
      varSubAddress = .SubAddress
      varLabel = .TextToDisplay
      .Delete
    End With
    .MoveRight wdCharacter, Len(varLabel), wdExtend
    .Hyperlinks.Add .Range, varAddress, varSubAddress, , varLabel
  End With
  
End Sub
Regards
Don

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

Thanks, Don! I'll try that on my (offensive) document!
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

Don, I encounter a 5941 error when I try to run your code on a trial document with a followed hyperlink:
Err5941.JPG
Debug gives me the attached.
You do not have the required permissions to view the files attached to this post.
Sundog

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Unfollow a Hyperlink color

Post by Don Wells »

Sundog wrote:Don, I encounter a 5941 error when I try to run your code on a trial document with a followed hyperlink:.
Are you certain that your selection included or was part of the hyperlink? The error code says that it did not.
Regards
Don

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

Ah so. This time I did a Ctrl+A, and got a 5824 error, .Hyperlinks.Add .Range, varAddress, varSubAddress, , varLabel highlighted.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

Here is my test doc.
You do not have the required permissions to view the files attached to this post.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Unfollow a Hyperlink color

Post by Sundog »

Despite the 5824 error, when I return to my test document, the hyperlink HAS been reset to unfollowed. So something good IS happening.
Sundog

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Unfollow a Hyperlink color

Post by Don Wells »

Sundog wrote:Despite the 5824 error, when I return to my test document, the hyperlink HAS been reset to unfollowed. So something good IS happening.
    Sorry; but I can find no problems when testing your file in Word 2003. Perhaps one of our Loungers with 2007 can offer some comment.
Regards
Don

User avatar
HansV
Administrator
Posts: 78489
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Unfollow a Hyperlink color

Post by HansV »

I get the same error as Sundog in Word 2007. If I modify the code slightly, Word crashes.
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Unfollow a Hyperlink color

Post by Don Wells »

HansV wrote:I get the same error as Sundog in Word 2007. If I modify the code slightly, Word crashes.
:groan: I guess that we must put this down to the price of progress as defined by MicroSoft. :groan:
Regards
Don