Spelling check in user form in VBA

2019-09-13 02:38发布

I want to check spelling in all labels that I have in a user form in VBA.

I would appreciate it if anyone could help me.

1条回答
Rolldiameter
2楼-- · 2019-09-13 03:00

enter image description here

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
查看更多
登录 后发表回答