View Single Post
 
Old 10-26-2018, 12:29 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is simply a matter of moving the range as appropriate e.g.
Code:
Sub Macro1()
Dim Ff As FormField, Rng As Range
Dim MainTable As Table
    Set MainTable = ActiveDocument.Tables(1)
    Set Rng = MainTable.Cell(14, 1).Range
    Rng.End = Rng.End - 1
    Rng.Text = "This is some text "
    Rng.Collapse 0
    Set Ff = Rng.FormFields.Add(Rng, wdFieldFormCheckBox)
lbl_Exit:
    Set Rng = Nothing
    Set Ff = Nothing
    Exit Sub
End Sub
Personally I would recommend using content controls rather than form fields so
Code:
Sub Macro2()
Dim CC As ContentControl, Rng As Range
Dim MainTable As Table
    Set MainTable = ActiveDocument.Tables(1)
    Set Rng = MainTable.Cell(14, 1).Range
    Rng.End = Rng.End - 1
    Rng.Text = "This is some text "
    Rng.Collapse 0
    Set CC = Rng.ContentControls.Add
    With CC
        .Type = wdContentControlCheckBox
        .Tag = "Check1"
        .Title = .Tag
        .Checked = False
        .LockContentControl = True
    End With
lbl_Exit:
    Set Rng = Nothing
    Set CC = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote