![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Elan05,
The code works OK in my testing, but it relies on there being only one formfield per row. That's because, having got a row count, it then proceeds to apply that to a count of formfields. So, if your table has 10 rows, with two formfields per row, but only the formfields in the first 5 rows are completed, no rows will be deleted. Also, as coded, the macro doesn't stop at the first row containing a filled formfield - within the above limitations it tests every row and, if it doesn't find a filled formfield there, deltes the row. That means it will also delete rows that have no formfields (eg a header row). Try the following: Code:
Sub DeleteEmptyRows()
'Delete empty rows in the table after all equipment has been entered
Application.ScreenUpdating = False
Dim StrPwd As String
StrPwd = "a"
With ActiveDocument
.Unprotect Password:=StrPwd
With .Tables(1).Rows
While .Last.Range.FormFields(1).Result = ""
.Last.Delete
Wend
End With
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=StrPwd
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| delete row, form fields, protected form |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Text Form Fields - Filling the table cell
|
simville02 | Word Tables | 1 | 01-31-2013 11:12 PM |
| Using macro to add variable number of rows to a protected word table | Julia | Word Tables | 1 | 01-09-2013 06:04 AM |
Delete all rows but the last.
|
elky1967 | Word VBA | 14 | 09-21-2012 05:27 AM |
| Adding table lines to protected form | razberri | Word Tables | 2 | 10-27-2010 05:58 PM |
| Editing Password protected form fields in Word 2007 | tamilan | Word | 2 | 02-16-2010 09:45 AM |