![]() |
#1
|
|||
|
|||
![]()
Hello,
I am creating a form that will be used as a letter for many salesman in my company. I created a form field in the last row of a table. Following the table is another paragraph. The form field I am referring to will be optional to fill in, it will only be used if someone needs to include a special note in the letter (most of the time this form field will remain empty). I am trying to create a macro that inserts an extra row IF the form field is populated. If the user skips over the form field without typing anything, I don't want the row to be inserted. I have tried so many different macros trying to figure this out, I was able to get some of them to insert the row on exit of the form field, but it inserted the row, whether the form field was populated or not. Can anyone help?! |
#2
|
|||
|
|||
![]()
So it is a text input formfield; and it does not matter what text is input. ANY text will make a new row.
|
#3
|
|||
|
|||
![]()
Yes, exactly!
|
#4
|
|||
|
|||
![]()
I don't think anyone ever replied back? Is this impossible to do?!
|
#5
|
|||
|
|||
![]()
Try an OnExit macro like:
Code:
Sub If_Text() Dim oTbl As Table Set oTbl = Selection.Tables(1) If ActiveDocument.FormFields("Text1").Result <> "" Then ActiveDocument.Unprotect oTbl.Rows.Add ActiveDocument.Protect _ Type:=wdAllowOnlyFormFields, NoReset:=True End If End Sub |
#6
|
|||
|
|||
![]()
YES! That worked perfectly! Thank you!
|
![]() |
Tags |
form fields, insert row, macro |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
iiiiifffff | Word VBA | 16 | 06-04-2016 01:47 AM |
Change values in cells based on criteria | SaneMan | Excel Programming | 2 | 02-02-2012 07:58 AM |
![]() |
LAssist2011 | Word | 5 | 12-14-2011 03:02 PM |
Macro to populate a text form field based on dropdown selection | koloa | Word | 0 | 10-20-2011 11:52 AM |
![]() |
DKerne | Word VBA | 4 | 06-09-2011 11:54 AM |