Get Properties is selected from Dialogs(xlDialogFontProperties) at the UserForm Level (not Worksheet)

saeedfiroozei

New Member
Joined
Nov 15, 2024
Messages
5
Office Version
  1. 365
Platform
  1. Windows
hello everyone
I got stuck in this issue. I want the user to call the Dialogs(xlDialogFontProperties) in a UserForm by a CommandButton, and after selecting the desired font, its size, style, and color, the selected Properties Could be applied to the caption of all other CommandButtons.Is there any Solution? Here Is my code:
#
Dim MyfontDialog As Variant
Dim FontProperty As MainSetting_clsFontSetting 'This Is A class That Have All Font Properties
Dim i As Long
Dim MyControl As MSForms.Control
Dim ObjVbComponent As Object
Dim MyUsf As UserForm

MyfontDialog = Application.Dialogs(xlDialogFontProperties).Show

If Not IsNull(MyfontDialog) Then 'Check User Didn't Cancel
For Each ObjVbComponent In ThisWorkbook.VBProject.VBComponents 'Loop Through all USerForms in ThisWorkbook
If ObjVbComponent.Type = vbext_ct_MSForm Then 'ChecK Type Of UserForm
Set MyUsf = ObjVbComponent.Designer
For Each MyControl In MyUsf.Controls 'Loop Through all Controls In UserForm
If TypeOf MyControl Is MSForms.CommandButton Then 'Check The Control IS CommandButton Type
MyControl.Font.Name = MyfontDialog.SelectedItem(1).Name
MyControl.Font.Bold = MyfontDialog.SelectedItem(1).Bold
MyControl.Font.Size = MyfontDialog.SelectedItem(1).Size
MyControl.Font.Italic = MyfontDialog.SelectedItem(1).Italic
End If
Next MyControl
End If
Next ObjVbComponent
End If

Can Anybody help Me? thnx a lot
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
That dialog changes the font of the activecell, so you could simply replace this: MyfontDialog.SelectedItem(1) with this: ActiveCell.Font
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,120
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top