Thread: Autosize
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Autosize

Hi Kirk,

Firstly are you using MS Excel? The code you posted suggests you might be
using something else.

Anyway assuming it is MS Excel your first question: Try setting the property
Wordwrap to false. Excel becomes confused with Autosize if it is set to true
and then font sizes and length of text etc is changed.

Second question: Following code might help if you are using MS Excel.

Dim newtextstring As String

newtextstring = "My New Label Name"

'Label1.AutoSize = False 'Superfluous line.
'Label1.Caption = "" 'Superfluous line. Not required when changing caption
Label1.Caption = newtextstring
Label1.AutoSize = True
Label1.Font.Size = 12 ' Included for demo purposes only

Can also use following line in lieu of using a variable for the caption.
Label1.Caption = "My New Label Name"

Feel free to get back to me if still having problems but let me know what
version of Excel you are using

--
Regards,

OssieMac


"kirkm" wrote:


Anyone know why autosize sometimes increases label height
far in excess of what it should be? It occurs after the label text is
changed to something smaller, then restored to what it was.

Should this logic to reset work?. It isn't!

Set Autosize False
Set label1 = ""
Assign label1= newtextstring
Set Autosize True

Also when autosize causes descenders to be cropped, can you append a
blank line (to the label)?

Thanks - Kirk