Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Dec 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Font selection User Form (Word XP)

    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???

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Font selection User Form (Word XP)

    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.)

  3. #3
    Lounger
    Join Date
    Dec 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Font selection User Form (Word XP)

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

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Font selection User Form (Word XP)

    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:

    <pre>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
    </pre>

    Gary

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Font selection User Form (Word XP)

    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
    <pre>'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</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •