Skip to content

Instantly share code, notes, and snippets.

@AlexLynd
Last active September 24, 2021 13:13
Show Gist options
  • Save AlexLynd/03fab1fb6dadd6d6297355f42fe2f5e2 to your computer and use it in GitHub Desktop.
Save AlexLynd/03fab1fb6dadd6d6297355f42fe2f5e2 to your computer and use it in GitHub Desktop.
VB script that inserts checkbox before selected lines in Microsoft Word
Sub checkBoxAppend()
Dim lineCnt As Integer
lineCnt = Selection.Range.Sentences.Count
Dim Words
For Words = lineCnt To 1 Step -1 '
Selection.MoveStartUntil "&", wdBackward
Selection.MoveLeft 1
Dim objCC As ContentControl
Set objCC = ActiveDocument.ContentControls.Add(wdContentControlCheckBox)
objCC.Checked = False
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Expand wdLine
Next Words
Selection.MoveStartUntil "&", wdBackward
Selection.MoveLeft 1
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment