MS Word旧式表单文本表单字段限制编辑,但更改字体大小

问题描述

enter image description here

在限制编辑下,用户只能添加删除单词。我可以只允许用户更改字体大小吗?

解决方法

您将不得不编写一个kluge来显示字体大小的用户窗体,然后取消保护窗体,设置字体大小并重新保护。此示例不包含用户表单:

Dim FontSize As Long

Sub SetSize()
    FontSizeDlg.Show    'Dialog allows user to choose size,which sets the FontSize variable
    With ActiveDocument
        If .ProtectionType = wdAllowOnlyFormFields Then
            .Unprotect
        End If
        .Bookmarks("Name").Range.Font.Size = FontSize
        .Bookmarks("Class").Range.Font.Size = FontSize
        If .ProtectionType = wdNoProtection Then
            .Protect Type:=wdAllowOnlyFormFields,noreset:=True
        End If
    End With
End Sub