![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Elan05, Your document has multiple tables. You could achieve what you're after simply by changing .Tables(1).Rows to .Tables(2).Rows, though if you had a schedule with no items, the code would produce an error as the 3rd row has no formfields. The modified code below runs without producing an error in such cases: Code:
Sub DeleteEmptyRows()
'Delete empty rows in the table after all equipment has been entered
Application.ScreenUpdating = False
Dim StrPwd As String
StrPwd = ""
With ActiveDocument
If .ProtectionType = wdAllowOnlyFormFields Then .Unprotect Password:=StrPwd
With .Tables(2).Rows
Do While .Last.Range.FormFields.Count > 0
If .Last.Range.FormFields(1).Result = "" Then
.Last.Delete
Else
Exit Do
End If
Loop
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 |