Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dialog box selection type ORLANDO VAZQUEZ[_2_] Excel Discussion (Misc queries) 1 September 30th 09 08:24 PM
Dialog Box and mouse selection djExcel Excel Programming 2 November 5th 07 12:23 PM
Get Font Color Dialog Zone Excel Programming 2 November 18th 06 06:57 PM
VBA with Font dialog without use comdlg.ocx Joe Excel Programming 1 November 26th 04 09:18 AM
Dialog Box Confirmation Selection Annie[_2_] Excel Programming 1 August 24th 03 02:49 PM


All times are GMT +1. The time now is 02:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"