By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

excel cell format

100+
P: 142
in excel VBA, we can use cells(1,1).Font.ColorIndex to find out that text's color in cell(1,1), but how can we find out the font, font style (bold, italic, and underline) about that text?
thanks
Apr 17 '07 #1
Share this Question
Share on Google+
6 Replies


SammyB
Expert 100+
P: 807
in excel VBA, we can use cells(1,1).Font.ColorIndex to find out that text's color in cell(1,1), but how can we find out the font, font style (bold, italic, and underline) about that text?
thanks
It's all in the Font object. Hint, if you create a Range object & set the cell to that object, then Intellisense will show you all of the properties:
Expand|Select|Wrap|Line Numbers
  1.     Dim r As Range
  2.     Set r = ActiveCell
  3.     MsgBox r.Font.FontStyle
  4.     MsgBox r.Font.Name
  5.     MsgBox r.Font.Bold
  6.     MsgBox r.Font.Size
  7.  
Apr 17 '07 #2

100+
P: 142
Thanks, Sam.
You help me on resize a textbox before,
ashape.Cells("width").Formula = "50mm",
but this time i need to autosize the textbox so the textbox can fit each line of text.
For example, the text sometime is 123456, but sometime is 12345678910, so I can not specify the size of the textbox.
Apr 18 '07 #3

dbanning
P: 19
You can do this from excel directly by setting the wdth to autofit selection. Than it will autoamatically change to fit the contents or you can use


Selection.Columns.AutoFit
Selection.Rows.AutoFit
Apr 18 '07 #4

SammyB
Expert 100+
P: 807
Thanks, Sam.
You help me on resize a textbox before,
ashape.Cells("width").Formula = "50mm",
but this time i need to autosize the textbox so the textbox can fit each line of text.
For example, the text sometime is 123456, but sometime is 12345678910, so I can not specify the size of the textbox.
Did you change the subject? :(
For anyone else reading, we are now talking about the size of Visio Shapes.

Anyway, I thought Visio automatically resized the shape for you, and/or you used the TEXTWIDTH function in the formula. Seems like you already have the code, celObjWidth.Formula = "=GUARD(TEXTWIDTH(TheText))", but make sure you have applied the font formatting first as that will affect the TEXTWIDTH.
Apr 18 '07 #5

100+
P: 142
I try "=GUARD(TEXTWIDTH(TheText))" before, but I just cannot make it work. Should I use
ashape.celObjWidth.Formula="=GUARD(TEXTWIDTH(TheTe xt))"

Did you change the subject? :(
For anyone else reading, we are now talking about the size of Visio Shapes.

Anyway, I thought Visio automatically resized the shape for you, and/or you used the TEXTWIDTH function in the formula. Seems like you already have the code, celObjWidth.Formula = "=GUARD(TEXTWIDTH(TheText))", but make sure you have applied the font formatting first as that will affect the TEXTWIDTH.
Apr 18 '07 #6

100+
P: 142
I try "=GUARD(TEXTWIDTH(TheText))" before, but I just cannot make it work. Should I use
ashape.celObjWidth.Formula="=GUARD(TEXTWIDTH(TheTe xt))"
never mind, got it work.
Apr 18 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.