I am trying to find some documentation to help implement
the application.dialogs
I want to be able to give the user the ability to change the font, font size and style of text they enter in a TextBox on a UserForm
Thanks
Printable View
I am trying to find some documentation to help implement
the application.dialogs
I want to be able to give the user the ability to change the font, font size and style of text they enter in a TextBox on a UserForm
Thanks
afaik the font dialog will only change the font settings of the current selection, not any part of a userform
what you can do is save all the font settings of the selection to variables, then after showing the dialog set the font settings of the textbox, to those of the selection, reset the selection fonts back to original from the saved settings, on closing the userform
Application.Dialogs(xlDialogFormatFont).Show
How do I capture the setting values?
did you read my previous post?Quote:
How do I capture the setting values?
Quote:
then after showing the dialog set the font settings of the textbox, to those of the selection
vb Code:
with textbox1 .font.name = selection.font.name .font.size = selection.font.size .font.bold = selection.font.bold 'etc end with
Yes I did read your post thanks I cam up with this based on your help
which seems to be exactly what you posted here
With Worksheets("Sheet1").Range("AB1").Select
UserForm1.TextBox2.Font.Name = Selection.Font.Name
UserForm1.TextBox2.Font.Size = Selection.Font.Size
UserForm1.TextBox2.Font.Bold = Selection.Font.Bold
UserForm1.TextBox2.Font.Italic = Selection.Font.Italic
Application.Dialogs(xlDialogFontProperties).Show
End With
I just set the selection to a way off cell and then retrieved the values, its working great
Thanks for your help
you actually need to show the dialog before setting the textbox font, so as to pick up the changes
Ok I seem to have it working except there is a problem if the color is set to automatic I get an error on the last line: "Could Not set the Forecolor property invalid property value"
It appears "automatic" under font color selection in the format cells is a -268......somethingCode:Worksheets("Sheet1").Range("AC1").Select
Application.Dialogs(xlDialogFontProperties).Show
EmailForm.TextBox3.Font.Name = Selection.Font.Name
EmailForm.TextBox3.Font.size = Selection.Font.size
EmailForm.TextBox3.Font.Bold = Selection.Font.Bold
EmailForm.TextBox3.Font.Italic = Selection.Font.Italic
EmailForm.TextBox3.ForeColor = Selection.Font.ColorIndex
try
you may needvb Code:
EmailForm.TextBox3.ForeColor = Selection.Font.Color
vb Code:
if not selection.font.colorindex = -4105 then EmailForm.TextBox3.ForeColor = Selection.Font.Color