I have a table on my form that needs to have a new row
added as the user fills the last one. To do this I have
to run a macro that unprotects the table (form) and then
creates the new row after which it re-protects it all
again. When the form is re-protected i lose all the
forms data, anyone know a way round this??
My Code:
Sub createnewaction()
'
' createnewaction Macro
' A Macro to Create a New Action Row
'
ActiveDocument.Unprotect
Selection.InsertRowsBelow 1
Selection.HomeKey Unit:=wdLine
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1)
.Name = "Dropdown1"
.EntryMacro = ""
.ExitMacro = ""
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
End With
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Clear
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Add Name:= _
" "
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Add Name:= _
"Adam Thickett"
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Add Name:= _
"Alex Manning"
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Add Name:= _
"Luke Fowler"
Selection.FormFields
("Dropdown1").DropDown.ListEntries.Add Name:="Simon"
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range,
Type:= _
wdFieldFormTextInput
Selection.PreviousField.Select
With Selection.FormFields(1)
.Name = "Text8"
.EntryMacro = ""
.ExitMacro = ""
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdRegularText, Default:="",
Format:="Title case"
.Width = 0
End With
End With
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range,
Type:= _
wdFieldFormTextInput
Selection.PreviousField.Select
With Selection.FormFields(1)
.Name = "Text9"
.EntryMacro = ""
.ExitMacro = "createnewaction"
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdDateText, Default:="",
Format:="dd MMM"
.Width = 0
End With
End With
Selection.MoveLeft Unit:=wdCell
Selection.MoveLeft Unit:=wdCell
ActiveDocument.Protect Type:=wdAllowOnlyFormFields
End Sub
TTFN
Adam Thickett
Change "ActiveDocument.Protect Type:=wdAllowOnlyFormFields" to
"ActiveDocument.Protect wdAllowOnlyFormFields,True".
The additional argument is the NoReset parameter and this stops Word from
resetting all the FormFields.
HTH + Cheers - Peter
"Adam Thickett" <anon...@discussions.microsoft.com> wrote in
news:999501c3eb4c$87439160$a101...@phx.gbl: