#1
|
|||
|
|||
Capture a Font in a Variable
On a userform, I have various labels that I need to set the font on at form initialization based on the version of Excel that the user has (since different fonts are available on different versions of Excel). Here is what I have but it is crashing on me:
Code:
Private Sub UserForm_Initialize() Dim myFont As Font 'Set fonts on controls based on version of Excel If Application.Version > 12 Then 'this is for Excel 2010 myFont = "Chiller" Else: myFont = "Arial" 'older versions of Excel End If 'Set the various controls Me.Label1.Font = myFont Me.Label2.Font = myFont Me.Label3.Font = myFont 'etc Can anybody tell me how to capture the name of a font in a variable so that I can use this variable to set the fonts on my different labels (and other controls)? Thanks. |
#2
|
|||
|
|||
I figured it out. Here is the code for anyone who might stumble on this:
Code:
Private Sub UserForm_Initialize() Dim myFont As String 'Set fonts on controls based on version of Excel If Application.Version > 12 Then 'this is for Excel 2010 myFont = "Chiller" Else: myFont = "Arial" 'older versions of Excel End If 'Set the various controls Me.Label1.Font.Name = myFont 'etc |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to capture start and ending Ref. Nos. in an array | KIM SOLIS | Excel | 5 | 09-07-2011 07:43 AM |
Variable fields? | Emalee77 | PowerPoint | 0 | 01-30-2011 05:58 PM |
Variable Table_Array in VLOOKUP | pdab09 | Excel | 3 | 11-23-2010 05:28 AM |
capture sender's contact to 'Contacts Folder' | gianimpact | Outlook | 0 | 02-09-2010 07:56 AM |
Inputting variable data | axy | Word | 0 | 09-08-2009 04:50 PM |