Hi All;
I am trying to add a new row in a table only when the last field in the table is not blank. Currently I have the code for adding the line and blank fields. I can run the code when the field is exited without any issues.
Several things that I would like to do:
1) I want to only activate this on the last field on the last row of the table only if it is not blank
2) I don't know how to do this based on a random field bookmark name that is created from the following code
3) How do I de-activate the code in any lines above the new blank table row and field where this code has already been been run
The code currently activates on the exiting of form field. There are some issues.
1) If statement is not correctly activating due to me not knowing the proper formula to activate the if statement
2) In the second with statement, I don't know how to update the form field name from the current name "Text52" to the newly created form field
3) Other issues are also occuring
any assistance would be appreciated.
Mike
I am trying to add a new row in a table only when the last field in the table is not blank. Currently I have the code for adding the line and blank fields. I can run the code when the field is exited without any issues.
Several things that I would like to do:
1) I want to only activate this on the last field on the last row of the table only if it is not blank
2) I don't know how to do this based on a random field bookmark name that is created from the following code
3) How do I de-activate the code in any lines above the new blank table row and field where this code has already been been run
The code currently activates on the exiting of form field. There are some issues.
1) If statement is not correctly activating due to me not knowing the proper formula to activate the if statement
2) In the second with statement, I don't know how to update the form field name from the current name "Text52" to the newly created form field
3) Other issues are also occuring
any assistance would be appreciated.
Mike
Code:
Sub test()
If Selection.FormFields > 0 Then
Selection.InsertRowsBelow 1
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
With Selection.FormFields(1)
With Selection.FormFields
'.Name = "Text52"
.EntryMacro = ""
.ExitMacro = "test"
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdRegularText, Default:="", Format:=""
.Width = 0
End With
End With
Else: End If
End Sub