Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2013, 01:35 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,527
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,




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

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 10:50 AM.


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