简体   繁体   中英

Spelling check in user form in VBA

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.

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM