![]() |
Font selection dialog box?
Hello,
I need to be able to have the user select a font from the installed fonts, and return the font name to af string-variable. I've tried some of the builtin dialogs: .Dialogs(xlDialogActiveCellFont) .Dialogs(xlDialogFont) .Dialogs(xlDialogFontProperties) .Dialogs(xlDialogFormatFont) But, in all these dialogs, the user can change/select all sorts of font properties, besides the name, ie. the color, bold, underlined, size, etc... Besides, these dialogs require quite some programming to save the font name to a string-variable! I need a dialog where only the font names can be choosen from? Does such a dialog exists? Perhaps it needs to be done with a UserForm? But then, how to populate a listboks with the names of the installed fonts? Help apreciated, Thanks in advance... |
Font selection dialog box?
'In a standard module... Sub GiveMeSomeFonts() Dim vReturn As Variant UserForm1.Show vReturn = UserForm1.ComboBox1.Value 'for demonstration MsgBox vReturn Unload UserForm1 End Sub '--- 'In a UserForm module with a ComboBox and two Command buttons on the userform... Private Sub CommandButton1_Click() 'OK button Me.Hide End Sub Private Sub CommandButton2_Click() 'Cancel button Me.Hide End Sub Private Sub UserForm_Initialize() 'Jim Cone - Portland Oregon USA - July 2010 Dim cmdFontCtrl As CommandBarControl Dim cmdTempBar As CommandBar Dim i As Long Set cmdFontCtrl = _ Application.CommandBars("Formatting").FindControl( ID:=1728) 'If Font control is missing, create a temp CommandBar If cmdFontCtrl Is Nothing Then Set cmdTempBar = Application.CommandBars.Add Set cmdFontCtrl = cmdTempBar.Controls.Add(ID:=1728) End If For i = 0 To cmdFontCtrl.ListCount - 1 Me.ComboBox1.AddItem cmdFontCtrl.List(i + 1) Next ' i Me.ComboBox1.ListIndex = 0 If Not cmdTempBar Is Nothing Then cmdTempBar.Delete Set cmdTempBar = Nothing End If Set cmdFontCtrl = Nothing End Sub '-- Jim Cone Portland, Oregon USA Special Sort add-in: http://www.contextures.com/excel-sort-addin.html .. .. .. "Charlotte E" wrote in message ... Hello, I need to be able to have the user select a font from the installed fonts, and return the font name to af string-variable. I've tried some of the builtin dialogs: .Dialogs(xlDialogActiveCellFont) .Dialogs(xlDialogFont) .Dialogs(xlDialogFontProperties) .Dialogs(xlDialogFormatFont) But, in all these dialogs, the user can change/select all sorts of font properties, besides the name, ie. the color, bold, underlined, size, etc... Besides, these dialogs require quite some programming to save the font name to a string-variable! I need a dialog where only the font names can be choosen from? Does such a dialog exists? Perhaps it needs to be done with a UserForm? But then, how to populate a listboks with the names of the installed fonts? Help apreciated, Thanks in advance... 'means nothing JBC |
Font selection dialog box?
Works like a charm :-) Thanks, Jim :-) "Jim Cone" wrote in message ... 'In a standard module... Sub GiveMeSomeFonts() Dim vReturn As Variant UserForm1.Show vReturn = UserForm1.ComboBox1.Value 'for demonstration MsgBox vReturn Unload UserForm1 End Sub '--- 'In a UserForm module with a ComboBox and two Command buttons on the userform... Private Sub CommandButton1_Click() 'OK button Me.Hide End Sub Private Sub CommandButton2_Click() 'Cancel button Me.Hide End Sub Private Sub UserForm_Initialize() 'Jim Cone - Portland Oregon USA - July 2010 Dim cmdFontCtrl As CommandBarControl Dim cmdTempBar As CommandBar Dim i As Long Set cmdFontCtrl = _ Application.CommandBars("Formatting").FindControl( ID:=1728) 'If Font control is missing, create a temp CommandBar If cmdFontCtrl Is Nothing Then Set cmdTempBar = Application.CommandBars.Add Set cmdFontCtrl = cmdTempBar.Controls.Add(ID:=1728) End If For i = 0 To cmdFontCtrl.ListCount - 1 Me.ComboBox1.AddItem cmdFontCtrl.List(i + 1) Next ' i Me.ComboBox1.ListIndex = 0 If Not cmdTempBar Is Nothing Then cmdTempBar.Delete Set cmdTempBar = Nothing End If Set cmdFontCtrl = Nothing End Sub '-- Jim Cone Portland, Oregon USA Special Sort add-in: http://www.contextures.com/excel-sort-addin.html . . . "Charlotte E" wrote in message ... Hello, I need to be able to have the user select a font from the installed fonts, and return the font name to af string-variable. I've tried some of the builtin dialogs: .Dialogs(xlDialogActiveCellFont) .Dialogs(xlDialogFont) .Dialogs(xlDialogFontProperties) .Dialogs(xlDialogFormatFont) But, in all these dialogs, the user can change/select all sorts of font properties, besides the name, ie. the color, bold, underlined, size, etc... Besides, these dialogs require quite some programming to save the font name to a string-variable! I need a dialog where only the font names can be choosen from? Does such a dialog exists? Perhaps it needs to be done with a UserForm? But then, how to populate a listboks with the names of the installed fonts? Help apreciated, Thanks in advance... 'means nothing JBC |
All times are GMT +1. The time now is 12:01 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com