blank table row

Q

QB

I have a doc which is comprised of several table that have been setup with
form fields for data entry.

Now I am looking to add a cmd button which would blank all the fields in the
select table row. How can this be done?

Basically, the user would place their cursor in one cell of the row, any
cell, and press a button and all the fields, in all the cells of that row
would be blanked.

Thank you in advance.

QB
 
G

Graham Mayor

The following macro will blank all the text formfields in the current row.
Check boxes are set to false and dropdown fields are set to the first listed
dropdown item

Dim bProtected As Boolean
Dim oFld As FormFields
Dim i As Long
Dim iRow As Integer
Dim oCell As Cell
Dim oTable As Table
iRow = Selection.Cells(1).RowIndex
Set oTable = Selection.Tables(1)
'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
For Each oCell In oTable.Rows(iRow).Cells
Set oFld = oCell.Range.FormFields
For i = 1 To oFld.Count
With oFld(i)
.Select
Select Case .Type
Case Is = wdFieldFormTextInput
oFld(i).Result = ""
Case Is = wdFieldFormDropDown
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Case Is = wdFieldFormCheckBox
oFld(i).CheckBox.Value = False
End Select
End With
Next
Next oCell
oTable.Cell(iRow, 1).Select
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
oTable.Cell(iRow, 1).Select

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Q

QB

I still have to test it out, but this is more than I expected! Thank you so
very much for the help!!!!

QB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top