saeedfiroozei
New Member
- Joined
- Nov 15, 2024
- Messages
- 5
- Office Version
- 365
- Platform
- 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
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