Consulting

Results 1 to 8 of 8

Thread: Hyperlinks and plain text content controls bug

  1. #1

    Hyperlinks and plain text content controls bug

    Hi,

    Do the following:
    1. Open a new document.
    2. Insert a table with one cell only
    3. Insert a Plain text content Control in the cell and write some text
    4. Below the table, write some text and bookmark it with the name "test"


    Copy the following into a new module and run it:

    Sub test()
        Dim CellRange As Range
        Set CellRange = ActiveDocument.Tables(1).Range.Cells(1).Range
        CellRange.Hyperlinks.Add CellRange, "#test"
    End Sub
    The plain text content control will now have a hyperlink pointing at the bookmarked text below.

    Now save it as .docm, close it and reopen it. Word will now complain that the document can't be opened and that Word found an error with its content. If the file is recovered Word removes the hyperlink.

    This must be a bug right? It seems like a plain text content control can't be hyperlinked, the hyperlink option is greyed out when trying to manually add the hyperlink to the content control, but when referencing the cell range in the hyperlinks.add method Word believes it's ok anyway.

    But it seems OK with a rich text content control though!

  2. #2
    The clue is in the name 'Plain Text'. A plain text control can only support plain text. A hyperlink is not plain text.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Yeah, agreed. But I mean, shouldn't Word throw an error when trying to hyperlink a plain text control as described above? I ended up spending a couple of hours searching for why my document was broken when reopening the file.

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,336
    Location
    Word 2010 does throw a RTE 4103 Out of Memory error. Word 2016 doesn't. Entire ranges of plain text controls can be formatted so "PLAIN" text is a bit misleading. Yes, I suppose it could be considered a bug.
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    VBAX Tutor
    Joined
    Jul 2016
    Posts
    266
    Location
    Instead of the "plain text content control" use a "repeating section content control" This worked for me in Word 2016.

  6. #6
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,336
    Location
    For the likely intended purpose, inserting the hyperlink text to a rich text CC range might be more appropriate. You will have to ensure that range is not showing placeholder text or you receive the same RTE4103 mentioned above.
    Last edited by gmaxey; 01-09-2017 at 08:37 AM.
    Greg

    Visit my website: http://gregmaxey.com

  7. #7
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by gmaxey View Post
    I suppose it could be considered a bug.
    Nah, probably just an undocumented feature
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  8. #8
    OK, thanks for the input everyone.

Posting Permissions

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