Private Sub btnOK_Click() If tbNumerator.Text <> "" And tbDenominator.Text <> "" Then fractionText = "EQ \F(" + tbNumerator.Text + "," + tbDenominator.Text + ")" Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ fractionText, PreserveFormatting:=False End If frmEnterFraction.Hide End Sub 单击命令按钮2(CommandButton2,btnCancel),为其添加一段命令处理程序如下:
Private Sub btnCancel_Click() frmEnterFraction.Hide End Sub 最后给窗体的激活事件(UserForm_Activate)添加如下程序段: Private Sub UserForm_Activate() Load frmEnterFraction End Sub