Without testing, I think you need
strSelection = CommandBars.ActionControl.Text
Klaus
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » 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
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.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications