View Single Post
 
Old 09-04-2018, 02:36 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try, for example:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim Tbl As Table, Rng As Range
If CCtrl.Title <> "Demo" Then Exit Sub
Application.ScreenUpdating = False
Set Rng = ActiveDocument.Bookmarks("Tbl").Range
Select Case CCtrl.Range.Text
  Case "Yes"
    If Rng.Tables.Count > 0 Then Exit Sub
    Set Tbl = Rng.Tables.Add(Range:=Rng, NumRows:=1, NumColumns:=2)
    With Tbl
      .AllowAutoFit = False
      .Borders.Enable = True
      .Rows.Height = InchesToPoints(0.75)
      .Columns(1).Width = InchesToPoints(2.5)
      .Columns(2).Width = InchesToPoints(3)
      With .Cell(1, 1).Range
        .Text = "Account:" & vbCr & " "
        .ContentControls.Add Type:=wdContentControlText, Range:=.Paragraphs(2).Range.Characters.First
        .ContentControls(1).Range.Text = ""
        .Paragraphs(1).Range.Font.Bold = True
      End With
      With .Cell(1, 2).Range
        .Text = "Remarks:" & vbCr
        .Paragraphs(1).Range.Font.ColorIndex = wdTurquoise
      End With
    End With
  Case Else
    If Rng.Tables.Count > 0 Then Rng.Tables(1).Delete
End Select
Set Tbl = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
Code in the attachment in post #6 updated.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote