Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Change UserForm font

Excel 2003
I have a label on a worksheet (which I added using the Control Toolbox
toolbar).
I don't know if it's an ActiveX control or not.
I want to programatically change the label's Font.
The following code doesn't work with the error message:-
Object doesn't support this Property or Method

ActiveSheet.Shapes("Label1").Select
Selection.Verb Verb:=xlOpen
Label1.Caption = "Accounts"
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 13
End With
I presume it's the syntax that's wrong.
Any suggestions would be appreciated.
--
donwb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Change UserForm font

Try some code like the following:

With Sheet1.Label1.Font
.Name = "Times New Roman"
.Size = 14
.Bold = True
' other properties to change
End With

Note that in the code above, "Sheet1" is the *CodeName* of the worksheet,
which is not necessarily the same as the Name of the sheet that appears in
the tabs in Excel. In VBA, if you CTRL R to open the Project window and
expand the Microsoft Excel Objects "folder" node for your workbook, you'll
see a list of worksheets. The names that are NOT within the parentheses are
the CodeNames (which is how VBA organizes itself). The names that are in
parens are the Sheet Names that appear on the tabs. Use the code name. This
has the advantage that the code will still work even if the sheet's name is
changed, since that doesn't change the code name.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"donbowyer" wrote in message
...
Excel 2003
I have a label on a worksheet (which I added using the Control Toolbox
toolbar).
I don't know if it's an ActiveX control or not.
I want to programatically change the label's Font.
The following code doesn't work with the error message:-
Object doesn't support this Property or Method

ActiveSheet.Shapes("Label1").Select
Selection.Verb Verb:=xlOpen
Label1.Caption = "Accounts"
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 13
End With
I presume it's the syntax that's wrong.
Any suggestions would be appreciated.
--
donwb


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Change UserForm font

Hi Chip
Many thanks. It now works.
--
donwb


"Chip Pearson" wrote:

Try some code like the following:

With Sheet1.Label1.Font
.Name = "Times New Roman"
.Size = 14
.Bold = True
' other properties to change
End With

Note that in the code above, "Sheet1" is the *CodeName* of the worksheet,
which is not necessarily the same as the Name of the sheet that appears in
the tabs in Excel. In VBA, if you CTRL R to open the Project window and
expand the Microsoft Excel Objects "folder" node for your workbook, you'll
see a list of worksheets. The names that are NOT within the parentheses are
the CodeNames (which is how VBA organizes itself). The names that are in
parens are the Sheet Names that appear on the tabs. Use the code name. This
has the advantage that the code will still work even if the sheet's name is
changed, since that doesn't change the code name.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"donbowyer" wrote in message
...
Excel 2003
I have a label on a worksheet (which I added using the Control Toolbox
toolbar).
I don't know if it's an ActiveX control or not.
I want to programatically change the label's Font.
The following code doesn't work with the error message:-
Object doesn't support this Property or Method

ActiveSheet.Shapes("Label1").Select
Selection.Verb Verb:=xlOpen
Label1.Caption = "Accounts"
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 13
End With
I presume it's the syntax that's wrong.
Any suggestions would be appreciated.
--
donwb


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Change UserForm font

Hi Chip
Just another point, how do I set or change the Caption of the Label?
--
donwb


"Chip Pearson" wrote:

Try some code like the following:

With Sheet1.Label1.Font
.Name = "Times New Roman"
.Size = 14
.Bold = True
' other properties to change
End With

Note that in the code above, "Sheet1" is the *CodeName* of the worksheet,
which is not necessarily the same as the Name of the sheet that appears in
the tabs in Excel. In VBA, if you CTRL R to open the Project window and
expand the Microsoft Excel Objects "folder" node for your workbook, you'll
see a list of worksheets. The names that are NOT within the parentheses are
the CodeNames (which is how VBA organizes itself). The names that are in
parens are the Sheet Names that appear on the tabs. Use the code name. This
has the advantage that the code will still work even if the sheet's name is
changed, since that doesn't change the code name.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"donbowyer" wrote in message
...
Excel 2003
I have a label on a worksheet (which I added using the Control Toolbox
toolbar).
I don't know if it's an ActiveX control or not.
I want to programatically change the label's Font.
The following code doesn't work with the error message:-
Object doesn't support this Property or Method

ActiveSheet.Shapes("Label1").Select
Selection.Verb Verb:=xlOpen
Label1.Caption = "Accounts"
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 13
End With
I presume it's the syntax that's wrong.
Any suggestions would be appreciated.
--
donwb


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Change UserForm font

Just another point, how do I set or change the Caption of the Label?

Sheet1.Label1.Caption = "Accounts"

Rick


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change scaling % but font size didnt change porportionally, pls he Scaling question Excel Discussion (Misc queries) 0 March 12th 07 03:16 AM
Change all text one font size up with various font sizes used. omchrystal New Users to Excel 2 March 6th 07 09:01 PM
Font in Userform Bill[_30_] Excel Programming 5 July 11th 06 04:11 PM
change display font to actual selected font Flannigan Excel Discussion (Misc queries) 1 August 30th 05 01:46 PM
Userform-Change textbox color and font based on input in other tex Neal Excel Programming 2 July 22nd 05 12:16 AM


All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"