Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get value from comboBox control (VBA/Word2003)

    Without testing, I think you need
    strSelection = CommandBars.ActionControl.Text

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  2. #2
    New Lounger
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get value from comboBox control (VBA/Word2003)

    Thanks Klaus, but I did try that, or rather;

    strSelection = CommandBars.ActionControl.TAG

    .Text is not valid property in this case. .Tag returns ""
    That said, I haven't set any 'tags' in the comboBox nor do I know whether I need to.

    Other suggestions? [img]/forums/images/smilies/wink.gif[/img]

    Cheers

  3. #3
    New Lounger
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get value from comboBox control (VBA/Word2003)

    Hi,

    I've searched, read, pulled hair and am now totally stumped!

    I am creating a conversion application that uses a limited font set. I've created a comboBox control and populated it with the allowable fonts. The problem is that I don't know how to get the value from the user's selection in the font list. Here's a sample of what I've got. I hope someone can help me. I'm sure it is easy and I've just totally overlooked something.

    Sub BuildFontList()
    Dim barFont
    Set barFont = CommandBars _
    .Add(Name:="Font", Position:=msoBarTop, _
    Temporary:=False)
    barFont.Visible = True

    Set ctrlFonts = barFont.Controls _
    .Add(Type:=msoControlComboBox)

    With ctrlFonts
    .AddItem "Arial"
    .AddItem "Arial Black"
    .AddItem "Book Antiqua"
    .AddItem "Century Gothic"
    .AddItem "Comic Sans MS"
    .AddItem "Verdana"
    .Style = msoComboLabel 'msoComboNormal
    .OnAction = "FontSelection" '"ScrollToQuarter"
    End With
    End Sub

    Sub FontSelection()
    '' ?? herehere??
    strSelection = ?? This is my test and where I am totally stuck.

    Once I can get the selected font, I'd use the following.
    Selection.Font = ActiveDocument.Fonts(??)

    End Sub

    If someone can fill in the gaps, that would be great.

    Cheers
    Greig.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get value from comboBox control (VBA/Word2003)

    Although .Text isn't listed as a property of ActionControl by IntelliSense, you can still use it. ActionControl can be any kind of commandbarcontrol, so IntelliSense doesn't know whether .Text is appropriate. But since your control is a combo box, it is valid.

    Another way to get the text would be

    strSelection = CommandBars("Font").Controls(1).Text

  5. #5
    New Lounger
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get value from comboBox control (VBA/Word2003)

    Thank you very much Hans and Klaus. You're both absolutely right!

    I thought I had actually tried that before too, but obviously I had something different because it didn't work previously.

    Thanks again, Greig.

Posting Permissions

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