View Single Post
 
Old 02-02-2017, 12:10 PM
michael.smith@safetech.ca michael.smith@safetech.ca is offline Windows 10 Office 2013
Novice
 
Join Date: Feb 2017
Posts: 1
michael.smith@safetech.ca is on a distinguished road
Default MS Word VBA macro to add a line to a table with formatting and set to original content

I am creating a MS Word form and want to give the option to "Add Education". This would be a macro button that would:
  • Unprotect the form
  • Add a line to an existing table with formatting
  • Set the new line to blank
  • Protect the form
I have a dropdown list in the first column of the table that would need to be set back to Choose and item

Attached is what I have found, but this just creates the form fields in the new row.

Sub AddTableRow()
Dim rw As Row
Dim cl As Cell
Dim ffld As FormField

ActiveDocument.Unprotect Password:=""
Set rw = ActiveDocument.Tables(4).Rows.Add
For lngIndex = 1 To oCol.Cells.Count
oCol.Cells(lngIndex).Range.Copy
.Columns(lngCol).Cells(lngIndex).Range.Paste
Next lngIndex
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub
Reply With Quote