Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 04-05-2013, 02:10 PM
macropod's Avatar
macropod macropod is offline Delete Rows in Protected Table with Form Fields Windows 7 64bit Delete Rows in Protected Table with Form Fields Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
 

Tags
delete row, form fields, protected form



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Rows in Protected Table with Form Fields 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 Rows in Protected Table with Form Fields 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft