Forum Discussion
Ezio-de-Pazzi
Dec 02, 2022Brass Contributor
UserForms are getting strange, please help.
This must be the weirdest phenomenon I've ever faced.
Normally in Userform.ListBox.Font.Italic should works just like a range.
Private Sub UserForm_Initialize()
'this would works as expected
UserForm1.ListBox1.RowSource = "Sheet1!A1:A3"
UserForm1.ListBox1.Font.Italic = True
UserForm1.ListBox1.Font.Italic = False
End Sub
But see these two samples below.
Private Sub UserForm_Initialize()
'this will NOT works! Just because i assigned a range variable. HOW STRANGE
'Notice the list is stil italic even if i set .Italic = False
Dim test_rng As Range
Set test_rng = [b5]
UserForm2.ListBox1.RowSource = "Sheet1!A1:A3"
UserForm2.ListBox1.Font.Italic = True
UserForm2.ListBox1.Font.Italic = False
'MsgBox UserForm2.ListBox1.Font.Italic 'you can uncomment this line to check .Italic property, it's still TRUE
End Sub
Private Sub UserForm_Initialize()
'this will NOT works same! Because i assigned wildcard characters combined with textbox value to a variable. GOSH STRANGE.
'Notice the list is stil italic even if i set .Italic = False
Dim test_str As String
test_str = UserForm3.TextBox1.Value & "*"
UserForm3.ListBox1.RowSource = "Sheet1!A1:A3"
UserForm3.ListBox1.Font.Italic = True
UserForm3.ListBox1.Font.Italic = False
'MsgBox UserForm3.ListBox1.Font.Italic 'you can uncomment this line to check .Italic property, it's still TRUE
End Sub
The codes self-explained.
It just doesn't make any sense! how could possibly assign a range variable or wildcard+textbox value affects the italic property of listbox.
And the most weird thing is to fix this, just assign italic property in other module.
Call fixed
------------------
Sub fixed()
UserForm3.ListBox1.Font.Italic = False
End Sub
I have uploaded a sample file to clarify the issue.
Please leave any thoughts below ...
- Gosh, I finally figured it out.
Turns out it all comes from the 64-bit Office. I tried to uninstall my office then reinstall 32-bit and it works PERFECTLY. >_<
I mean, come on Microsoft. It's 2022, I've been deploying 64-bit office to my colleague since 2016. And I don't regret it at all cause 64bit is sensible faster than 32bit to my workflow.
Guess the best workaround would be Call .font. Italic = false at others module. Thanks for your response ~
I cannot reproduce the problem. Even if I don't call fixed, the listbox font is not italic when I show UserForm2 and UserForm3.
I'm using Excel in Office 2021 on Windows 11. Which version of Office and which operating system do you use?
- Ezio-de-PazziBrass Contributor
What!
i have 3 devices, Windows 10 with Office 2016, Windows 10 with Office 2021, Windows 7 with Office 2010. All of them behaves the same issue ....here's a footage....
Oh, I don't doubt your experience at all. I've seen more than enough weird behavior...