Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-15-2013, 09:21 AM
Elan05 Elan05 is offline Delete Rows in Protected Table with Form Fields Windows 7 64bit Delete Rows in Protected Table with Form Fields Office 2010 64bit
Novice
Delete Rows in Protected Table with Form Fields
 
Join Date: Mar 2013
Posts: 13
Elan05 is on a distinguished road
Default Delete Rows in Protected Table with Form Fields

I am creating a document where the users will enter information in a table. I created a macro that allows the user to add rows as needed. I am trying to create a second macros that will run when the user exits the end of the table that will delete any rows that have all blank form fields.



I found this on another forum. I sent it to run when exiting the last form field of the table, the document flashes a few times so I can tell that it is running something but the blank rows did not delete. I am also not getting an error message. Can anyone help? What am I missing?!
Code:
Sub DeleteEmptyRows()
'
'Delete empty rows in the table after all equipment has been entered
'
ActiveDocument.Unprotect Password:="a"
Counter = ActiveDocument.Tables(1).Rows.Count
While Counter > 0
  If ActiveDocument.FormFields(Counter).Result = "" Then
    ActiveDocument.Tables(1).Rows(Counter).Delete
  End If
  Counter = Counter - 1
Wend
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="a"
End Sub

Last edited by macropod; 03-15-2013 at 05:08 PM. Reason: Added code tags & formatting
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 04:16 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