Results 1 to 6 of 6

VBA: How to add a hyperlink to a cell in a table in a Word doc

Threaded View

  1. #1
    Registered User
    Join Date
    10-18-2023
    Location
    Geel, Belgium
    MS-Off Ver
    Microsoft 365
    Posts
    3

    VBA: How to add a hyperlink to a cell in a table in a Word doc

    Hi all,

    I am new here and new to VBA coding. I am using and modifying an Excel VBA subroutine that generates a Word document with tables populated with information. Now I'm looking to add a snipet of code that lets me turn text in selected cells into hyperlinks.

    This is what imo relevant parts of the current code look like:

    (...)
        Dim wrdApp As Word.Application
        Dim wrdDoc As Word.Document
    (...)
        Set wrdApp = CreateObject("Word.Application")
        Set wrdDoc = wrdApp.Documents.Add
        wrdDoc.PageSetup.Orientation = wdOrientLandscape
    (...)
        Set objTable = wrdDoc.Tables(wrdDoc.Tables.Count)
        objTable.Style = "Table Grid"
    (...)
        With objTable
            .Cell(2, 2).Range.Text = Chr(10) & "TEXT A"
                .Cell(2, 2).Range.Font.Bold = True
            .Cell(4, 2).Range.Text = "TEXT B"
                .Cell(4, 2).Range.Font.Bold = True
    (...)
    Now I'd like to encode that e.g. hyperlink X is added to TEXT A in Cell (2,2).

    Does someone know which code to use?
    Last edited by alansidman; 10-18-2023 at 03:51 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hyperlink to word instead of cell
    By CharlieK in forum Excel General
    Replies: 5
    Last Post: 12-07-2016, 03:43 PM
  2. In Excel, Word Document hyperlink Table Cell partial text to bookmark.
    By Kalithro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2016, 11:16 PM
  3. Hyperlink excel cell to word
    By Luther.King in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-28-2015, 06:44 AM
  4. Replies: 0
    Last Post: 03-01-2013, 09:34 AM
  5. Replies: 1
    Last Post: 04-03-2012, 03:01 PM
  6. Hyperlink ONE word in a cell ???
    By mountainsun in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-07-2005, 11:06 PM
  7. [SOLVED] Hyperlink a word within a cell
    By kchambers in forum Excel General
    Replies: 2
    Last Post: 03-09-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1