none
Problem in Word when using VBA to insert symbol to the Caption of Label RRS feed

  • Question

  • I want to change a Female symbol to Male symbol or versus (font: "Webdings", charcode: 128 (Male) or ) on the Label (activeX control) in Word when click on label, but it doesn't work. Could everyone help me?

    Code like below:

     

    Private Sub Label1_Click()
    With Label1
        If .Caption = Chr(128) Then
            .Caption = Chr(129)
            .Font.Name = "Webdings"
        Else
            .Caption = Chr(128)
            .Font.Name = "Webdings"
        End If
    End With
    End Sub

     

    Thursday, July 28, 2011 7:21 AM

Answers

  • Try this:

    Private Sub Label1_Click()
        With Label1
            If .Caption = ChrW(128) Then
                .Caption = ChrW(129)
            Else
                .Caption = ChrW(128)
            End If
        End With
    End Sub

    On ChrW, from Word's Help: "The ChrW function returns a String containing the Unicode character except on platforms where Unicode is not supported, in which case, the behavior is identical to the Chr function."


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by chauvanphuoc Thursday, July 28, 2011 10:23 AM
    Thursday, July 28, 2011 8:11 AM
    Moderator

All replies

  • Try this:

    Private Sub Label1_Click()
        With Label1
            If .Caption = ChrW(128) Then
                .Caption = ChrW(129)
            Else
                .Caption = ChrW(128)
            End If
        End With
    End Sub

    On ChrW, from Word's Help: "The ChrW function returns a String containing the Unicode character except on platforms where Unicode is not supported, in which case, the behavior is identical to the Chr function."


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by chauvanphuoc Thursday, July 28, 2011 10:23 AM
    Thursday, July 28, 2011 8:11 AM
    Moderator
  • It worked now.

    Thanks Cindy very much!

    Thursday, July 28, 2011 10:24 AM