PDA

View Full Version : Coding outside borders



emmanpelayo
07-13-2015, 07:58 AM
Hi, all! Someone has done this coding for me. It enables adding an extra set of cells triggered by clicking the control that's in there. I was just wondering if someone could help me code, so that the extra set of cells are bordered in a box as seen in the first area (ICU) - I manually put the outside border here. As you could see, in this coding whenever an extra 'BAR set' is added it sort of blends in to the previous one. All I want is the extra set to be boxed in a border like the ICU portion.

emmanpelayo
07-13-2015, 08:24 AM
If it makes it easier, I only want a partition between the old and extra BAR sets so I guess I just want a top border above the B cells.

emmanpelayo
07-13-2015, 08:30 AM
This was Paul's code that he's done for me.

Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
Application.ScreenUpdating = False
Dim CCtrlRng As Range, TblRng As Range, i As Long, Prot As Variant, Pwd As String
With ActiveDocument
Set CCtrlRng = CCtrl.Range
If CCtrlRng.Information(wdWithInTable) Then
Set TblRng = CCtrlRng.Tables(1).Range
i = .Range(0, TblRng.End).Tables.Count
If (i = 1) Or (i = .Tables.Count) Then Exit Sub
If MsgBox("Add new BAR set?", vbQuestion + vbYesNo) = vbYes Then
Prot = .ProtectionType
If .ProtectionType <> wdNoProtection Then
Pwd = "" 'Insert password here
Prot = .ProtectionType
.Unprotect Password:=Pwd
End If
With TblRng
.Rows.Add
.MoveEnd wdCell, 2
.Cells(.Cells.Count - 1).Range.Text = "B:"
.Rows.Add
.MoveEnd wdCell, 2
.Cells(.Cells.Count - 1).Range.Text = "A:"
.Rows.Add
.MoveEnd wdCell, 2
.Cells(.Cells.Count - 1).Range.Text = "R:"
End With
.Protect Type:=Prot, Password:=Pwd
End If
End If
End With
Application.ScreenUpdating = True
End Sub