VBA 中用户表单的拼写检查

Spelling check in user form in VBA

我想检查 VBA 中用户表单中所有标签的拼写。

如果有人能帮助我,我将不胜感激。

Private Sub UserForm_Initialize()
Dim ctrl As Object

For Each ctrl In Me.Controls
    If TypeName(ctrl) = "Label" Then


        With ctrl
            If Not Application.CheckSpelling(.Caption) Then
                .ForeColor = vbRed
                .BackColor = vbYellow
            End If
        End With


    End If
Next
End Sub