Reputation: 81
I am building charts through excel-vba. I am using one of the lines below to make my X-axis fonts in bold:
Activechart.Axes(xlCategory).TickLabels.Font.FontStyle = "Bold"
Activechart.Axes(xlCategory).TickLabels.Font.Bold = msoTrue
Both of these methods work but I am wondering what is the difference.
Thanks
Upvotes: 1
Views: 3608
Reputation: 591
The Font.FontStyle = "Bold" didn't well as the .Font.Bold ...it didn't work because it takes, for example, the word "Bold", from the region settings of excel, in my case takes the word "Εντονα", which is the Bold in Greek. Now if you want to compare for example:
if the selection.Font.fontstyle="Bold" then...
In an excel with Greek regional settings, you will take wrong results.
It is safe to use.Font.Bold = True to avoid the above.
Upvotes: 1
Reputation:
You can use FontStyle to set multiple font properties at once
ActiveChart.Axes(xlCategory).TickLabels.Font.FontStyle = "Bold Italic"
With ActiveChart.Axes(xlCategory).TickLabels.Font
.Font.Bold = True
.Font.Italic = True
End With
Upvotes: 3