Log in

View Full Version : [SOLVED:] RichText CC Bug



gmaxey
01-16-2020, 05:29 PM
Hi gents (and ladies),

Posting a bug observation here for general consumption (comments). Will invite Jay Freedman from the Office Answers forum to review and possibly pass to the Word Development team (I'm not holding my breath that it will ever be fixed). The below image and attached .docm file will hopefully illustrate to you what I feel is a bug.

If you wrap a richtext contentcontrol around a table, such that the table is at the very top of the CC range and attempt some seemingly simple VBA steps on the first cell of the table then the CC can be destroyed (obviously not desired). If you step through the macros in the attached I'm guess you will see the same observations (I did this with Word 2010).

NOTE: I didn't want to monkey with you Normal template anymore than necessary so the BB created is deleted but you will get a prompt to save your Normal template.

25822

macropod
01-16-2020, 06:51 PM
If the CC is protected against deletion, you can't even write to the first cell in the table. Moreover, tables in CCs such as your document contains cannot be deleted - whether by VBA or otherwise - with or without the CC being protected against deletion. I drew the latter the MS's attention some years ago.

gmaxey
01-16-2020, 07:27 PM
Paul,

I know you are typically very thorough my friend, but "CANNOT"???


Sub ScratchMacroVII()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
Dim oCC As ContentControl
Dim oRng As Range
Set oCC = ActiveDocument.SelectContentControlsByTitle("Bug Demo 7").Item(1)
oCC.LockContents = False
Set oTbl = oCC.Range.Tables(1)
oTbl.ConvertToText
oCC.Range.Text = vbNullString
lbl_Exit:
Exit Sub
End Sub

This will leave the empty richtext control showing placeholder text. It seems, as you have deduced yourself that Word\VBA somehow commingles the start/end of the table range with the start/end of the CC range.

Edit - Paul I uploaded a revised file to illustrate. Does this address the issue you describe?

macropod
01-16-2020, 07:40 PM
Yes, you can do that, but you can't delete the table directly.

This will leave the empty richtext control showing placeholder text. It seems, as you have deduced yourself that Word\VBA somehow commingles the start/end of the table range with the start/end of the CC range.
If you switch Design Mode on, you'll see that Word has set the CC start within the tables...


A workaround for both issues is to insert a space before the table at the design stage. Another workaround for both issues is to switch the table's wrap format to 'around' while working on it.