locked
hyperlink font question RRS feed

  • Question

  • Is there a way to have the display 'www.' not bold 'google' bold '.com' not bold?

    here is what I got.

    Set objLink = objSelection.Hyperlinks.Add(objSelection.Range,"www.google.com")
    objLink.Range.Font.Name = "Verdana"
    objLink.Range.Font.Size = 9
    objLink.Range.Font.Bold = true
    objLink.Range.Font.underline = false
    objLink.Range.Font.Color = RGB(237,25,51)


    Rob Szarszewski

    Friday, November 2, 2012 1:06 PM

Answers

  • Try something based on:

    Sub Demo()
    Dim objLink As Hyperlink, StrLnk As String, Rng As Range
    StrLnk = "www.google.com"
    Set objLink = Selection.Hyperlinks.Add(Selection.Range, StrLnk)
    With objLink
      With .Range.Font
        .Name = "Verdana"
        .Size = 9
        .Bold = False
        .Underline = False
        .Color = RGB(237, 25, 51)
      End With
      Set Rng = .Range.Fields(1).Result
      With Rng
      .End = .Start + InStrRev(StrLnk, ".") - 1
      .Start = .Start + InStr(StrLnk, ".")
      .Font.Bold = True
      End With
    End With
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by RobSzar Saturday, November 3, 2012 11:26 PM
    Saturday, November 3, 2012 3:11 AM

All replies

  • Try something based on:

    Sub Demo()
    Dim objLink As Hyperlink, StrLnk As String, Rng As Range
    StrLnk = "www.google.com"
    Set objLink = Selection.Hyperlinks.Add(Selection.Range, StrLnk)
    With objLink
      With .Range.Font
        .Name = "Verdana"
        .Size = 9
        .Bold = False
        .Underline = False
        .Color = RGB(237, 25, 51)
      End With
      Set Rng = .Range.Fields(1).Result
      With Rng
      .End = .Start + InStrRev(StrLnk, ".") - 1
      .Start = .Start + InStr(StrLnk, ".")
      .Font.Bold = True
      End With
    End With
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by RobSzar Saturday, November 3, 2012 11:26 PM
    Saturday, November 3, 2012 3:11 AM
  • Thanks!

    Rob Szarszewski

    Saturday, November 3, 2012 11:26 PM