Hi,
Do the following:
- Open a new document.
- Insert a table with one cell only
- Insert a Plain text content Control in the cell and write some text
- Below the table, write some text and bookmark it with the name "test"
Copy the following into a new module and run it:
The plain text content control will now have a hyperlink pointing at the bookmarked text below.Sub test() Dim CellRange As Range Set CellRange = ActiveDocument.Tables(1).Range.Cells(1).Range CellRange.Hyperlinks.Add CellRange, "#test" End Sub
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!