Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Vertical Center Alignment for Labels

How do I center vertically in a label? I see how to center it horizontally
using the TextAlign property but I don't see a property that handles vertical
alignment.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Vertical Center Alignment for Labels

I don't think you can do that. Just double click the botton right hand
corner and the label dimensions will conform to the text in it. Hope this
helps! if so, let me know, click 'YES" below.

--
Cheers,
Ryan


"Bishop" wrote:

How do I center vertically in a label? I see how to center it horizontally
using the TextAlign property but I don't see a property that handles vertical
alignment.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Vertical Center Alignment for Labels

Where is this Label... on the worksheet or on a UserForm? If on the
worksheet, where did you get the Label from... the Forms toolbar or the
Control Toolbox toolbar?

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
How do I center vertically in a label? I see how to center it
horizontally
using the TextAlign property but I don't see a property that handles
vertical
alignment.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Vertical Center Alignment for Labels

It's in a userform that I created.

"Rick Rothstein" wrote:

Where is this Label... on the worksheet or on a UserForm? If on the
worksheet, where did you get the Label from... the Forms toolbar or the
Control Toolbox toolbar?

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
How do I center vertically in a label? I see how to center it
horizontally
using the TextAlign property but I don't see a property that handles
vertical
alignment.


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Vertical Center Alignment for Labels

I don't want to change the label dimensions.

"Ryan H" wrote:

I don't think you can do that. Just double click the botton right hand
corner and the label dimensions will conform to the text in it. Hope this
helps! if so, let me know, click 'YES" below.

--
Cheers,
Ryan


"Bishop" wrote:

How do I center vertically in a label? I see how to center it horizontally
using the TextAlign property but I don't see a property that handles vertical
alignment.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Vertical Center Alignment for Labels

Good! Are you up for a kludge solution? Use two Label controls... make the
first one the size you wanted the Label to originally be, then put a second
smaller Label control on top of it (don't worry where as we are going to
position it via code). Make the both Labels the same background color. Add a
border around the first (big) one if you want and remove its Caption. Make
sure the second (smaller) Label has no border and set its TextAlign property
to 2-fmTextAlignCenter. Now, just use code something like the following to
assign the text to the (AutoSize'd Label2) and then center that assigned
text (in the smaller Label) within the bigger Label. Here I'm assuming the
bigger Label is named Label1 and the smaller Label is named Label2 and I
also provided comments to explain why I did what I did...

With Label2
' First, assign your Multi-Line text to the smaller Label this way
.AutoSize = False
' Make the Label big enough to house your longest and tallest text
.Width = Label1.Width
.Height = Label1.Height
' Now assign the text using Line Feeds to separate lines of text
.Caption = "This is Line Number 1" & vbLf & _
"and here's Line 2"
' This next line shrinks the Label to the limit of the text
.AutoSize = True

' Next, center the smaller Label within the larger one
.Top = Label1.Top + (Label1.Height - .Height) / 2
.Left = Label1.Left + (Label1.Width - .Width) / 2
End With

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
It's in a userform that I created.

"Rick Rothstein" wrote:

Where is this Label... on the worksheet or on a UserForm? If on the
worksheet, where did you get the Label from... the Forms toolbar or the
Control Toolbox toolbar?

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
How do I center vertically in a label? I see how to center it
horizontally
using the TextAlign property but I don't see a property that handles
vertical
alignment.


.


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
How How do I change the default alignment to vertical center? Brian Setting up and Configuration of Excel 0 March 6th 09 03:50 PM
In Cell alignment, how do I update the default vertical alignment How to update default cell alignment Setting up and Configuration of Excel 2 February 4th 09 02:25 PM
Alignment: Center text but Right numbers. Brad E. Excel Worksheet Functions 2 August 19th 08 08:07 PM
Vertical Alignment Ren Excel Programming 3 December 31st 04 08:15 PM
Vertical Alignment of text in Userform labels dht Excel Programming 1 June 16th 04 01:58 PM


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

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

About Us

"It's about Microsoft Excel"