• Font selection User Form (Word XP)

    Author
    Topic
    #380440

    I been Word programming since Version 2 but have never played with Userforms. I want to have a form pop-up so that the user can select a new font and increment and decrement the fonts point size. Where do I start???

    Viewing 2 reply threads
    Author
    Replies
    • #637068

      I guess I’m lazier than you. I’d pop up a custom toolbar with the Font and Pont size drop downs duplicated from the Formatting toolbar. Building those from scratch just sounds like no fun at all! You could build increment and decrement macros, and then flank the point size drop down with command buttons of your own design to run them. However, if you need the UserForm for other reasons, the two things might not play well together. I haven’t tested.

      (I posted some code that reads and reacts to a user’s selection in a drop-down control. The thread had something to do with bookmarks, I believe. That might give you some pointers into the object model for commandbars and commandbar controls.)

    • #637101

      ….. I should have added that I need the name of the font and point size returned to use in a macro.

      • #637175

        Dennis,

        Jefferson’s suggestion to create a customized toolbar sounds like a really good one, but in any case to return the font name and size, you can do this:

        Public Sub ReturnFontNameAndPointSize()
        
           Dim strFontName As String
           Dim sngPtSize As Single
           
           With Selection.Font
              strFontName = .Name
              sngPtSize = .Size
           End With
           
           MsgBox "Selection font is " & strFontName _
                 & ", and font size is " & CStr(sngPtSize)
        
        End Sub
        

        Gary

    • #637295

      User forms are a bit tricky to get started in but its worthwhile to invest some time to figure out how they are done. This link (item 70) contains a reasonable description of how to create a user form. The demo is in Excel but the methodology is much the same in Word.

      When you have churned through that, post back and let us know where you are having problems. Gary has given you the genesis of getting the current font and typeface.

      Another hint is to use a macro called Userform_Initialize in the user form to put in the initial values of the lists or combo boxes. The code there might look something like this

      'Setting font size possibilities
        For x = 9 To 14
          Me.NormSizeCB.AddItem x
        Next x
      'Bringing in the style list possibilities 'NOT IN ORDER
        For Each aFont In FontNames
          Me.NormFontCB.AddItem aFont
        Next aFont
    Viewing 2 reply threads
    Reply To: Font selection User Form (Word XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: