我正在尝试永久更改用户窗体,以便我只需运行一次代码,而不是每次单击打开用户窗体的按钮时运行它。
我发现这对某些人有用。我不确定我可能有什么问题。
Sub FormatUserForms(UF As UserForm)
UF.BackColor = RGB(51, 51, 102)
Dim ctrl As Control
With ThisWorkbook.VBProject.VBComponents("UFNewRequest").Designer
For Each ctrl In UF.Controls
Select Case TypeName(ctrl)
Case "Label"
ctrl.BackColor = RGB(51, 51, 102)
ctrl.ForeColor = RGB(247, 247, 247)
Case "CommandButton"
ctrl.BackColor = RGB(247, 247, 247)
ctrl.ForeColor = RGB(0, 0, 0)
Case "TextBox"
ctrl.BackColor = RGB(247, 247, 247)
ctrl.ForeColor = RGB(0, 0, 0)
Case "OptionButton"
ctrl.BackColor = RGB(51, 51, 102)
ctrl.ForeColor = RGB(247, 247, 247)
End Select
Next
End With
End Sub
Sub formatting()
FormatUserForms UFNewRequest
End Sub
感谢您对此的任何帮助!