locked
VB: Microsoft Word - Selecting and Hyperlinking specific words within a Table Cell RRS feed

  • Question

  • How do I Select and Hyperlink specific words within a Table Cell?

    I've been googling and went here but I cannot find how to do what I need. I've tried variations on this and I can hyperlink the entire text in a cell, but I cannot seem to figure out how to hyperlink a specific word(s) within that cell as a range and hyperlink them?

    Thoughts or suggestions...?

    An abbreviated code example that has worked for me is this:

    Dim wdRng as Word.Range
    With oDoc.Tables(1)
    wdRng = .Cell(1, 1).Range
    oDoc.Hyperlinks.Add(wd, "http://www.microsoft.com")
    End With


    SV



    • Edited by svMSDN Friday, July 10, 2015 1:37 PM typo
    • Moved by Youjun Tang Wednesday, July 15, 2015 2:16 AM more appropriate
    Friday, July 10, 2015 1:35 PM

Answers

  • I did figure it out. So for those who need similar help in the future here was my solution.

    Dim wdRng as Word.Range
    With oDoc.Tables(1)
    wdRng = .Cell(1,1).Range
    wdRng.SetRange(20, 35)
    oDoc.Hyperlinks.Add(wdRng, "http://www.microsoft.com")
    End With


    SV

    Friday, July 10, 2015 6:03 PM