From: QB on 20 Jan 2010 09:32 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
From: Graham Mayor on 20 Jan 2010 10:32 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 My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "QB" <QB(a)discussions.microsoft.com> wrote in message news:504A403E-5528-44F5-8C6E-2911898716B4(a)microsoft.com... >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
From: QB on 20 Jan 2010 12:38 I still have to test it out, but this is more than I expected! Thank you so very much for the help!!!! QB "Graham Mayor" wrote: > 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 > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > "QB" <QB(a)discussions.microsoft.com> wrote in message > news:504A403E-5528-44F5-8C6E-2911898716B4(a)microsoft.com... > >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 > > > . >
|
Pages: 1 Prev: Thanks so much I have one other question Next: disable Submit button |