Microsoft Office Tutorials and References
In Depth Information
Forms: Formatting Text Input in Form Fields
Option explicit¶
' * * * * *¶
'First row containing form fields¶
'that should not be deleted¶
Const StartRowIndex As Long = 2¶
' * * * * *¶
Sub DeleteCurrentRow()¶
'Variable declaration¶
Dim doc As Word.Document¶
Dim rng As Word.Range¶
Dim totalRows As Long¶
Set rng = Selection.Range¶
If rng.Information(wdWithInTable) Then¶
'Make sure user can't accidentally delete¶
'any rows at the end, such as a totals row¶
'nor the last remaining "data row" in table¶
totalRows = rng.Tables(1).Rows.Count¶
If rng.Rows(1).Index <= totalRows - EndRowsIndex _¶
And totalRows > StartRowIndex + EndRowsIndex Then¶
Set doc = rng.Parent¶
If doc.ProtectionType <> wdNoProtection Then¶
doc.Unprotect password:=password¶
End If¶
rng.Rows(1).Delete¶
doc.Protect Type:=wdAllowOnlyFormFields, _¶
noreset:=True, password:=password¶
End If¶
End If¶
End Sub¶
Wrd
Follow these steps:
1. Copy the macros into a module in a forms document or in a template
from which protected forms are generated. Create a new toolbar and be
sure to save it in the same document or template as the macros.
2. Using Tools | Customize | Commands, with the category "Macros"
selected, drag each of the format-specific macro names ('FormatBold',
'FormatItalic', and 'FormatUnderline') to the toolbar to create a button
for each macro.
3. If the form is protected with a password, and the password is not
specified, the form cannot be unprotected so that the macro can apply
the formatting. If the form has no password, then the value for the
constant should be a zero-length string (""), as in the code procedure
example above.
Search JabSto ::




Custom Search