|
-
Jun 13th, 2012, 12:07 AM
#1
Thread Starter
Frenzied Member
Application.Dialogs(xlDialogFormatFont).Show
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
-
Jun 13th, 2012, 05:32 AM
#2
Re: Application.Dialogs(xlDialogFormatFont).Show
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 13th, 2012, 10:32 AM
#3
Thread Starter
Frenzied Member
Re: Application.Dialogs(xlDialogFormatFont).Show
Application.Dialogs(xlDialogFormatFont).Show
How do I capture the setting values?
-
Jun 13th, 2012, 04:10 PM
#4
Re: Application.Dialogs(xlDialogFormatFont).Show
How do I capture the setting values?
did you read my previous post?
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 13th, 2012, 04:16 PM
#5
Thread Starter
Frenzied Member
Re: Application.Dialogs(xlDialogFormatFont).Show
 Originally Posted by westconn1
did you read my previous post?
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
-
Jun 14th, 2012, 05:36 AM
#6
Re: Application.Dialogs(xlDialogFormatFont).Show
you actually need to show the dialog before setting the textbox font, so as to pick up the changes
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 18th, 2012, 02:44 PM
#7
Thread Starter
Frenzied Member
Re: Application.Dialogs(xlDialogFormatFont).Show
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"
Code:
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
It appears "automatic" under font color selection in the format cells is a -268......something
Last edited by billboy; Jun 18th, 2012 at 02:48 PM.
-
Jun 19th, 2012, 05:07 AM
#8
Re: Application.Dialogs(xlDialogFormatFont).Show
try
vb Code:
EmailForm.TextBox3.ForeColor = Selection.Font.Color
you may need
vb Code:
if not selection.font.colorindex = -4105 then EmailForm.TextBox3.ForeColor = Selection.Font.Color
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|