|
|||||||||||||||||||||
|
#1
|
|||
|
|||
|
Text Box Orientation in Excel 2007
Dear Friends,
When you run the code below in Excel 2007 why does is the text written vertically although I have specified "msoTextOrientationHorizontal" and AutoSize = True. This code runs fine in Excel 2003. Does anybody have a solution to this? Please help. Code:
Sub PlotTBox()
Dim dRectX As Double, dRectY As Double, dRectW As Double, dRectH As Double
Dim dStartPos As Double
Dim shTextBox As Shape
Dim strNameShort As String
dRectX = 50
dRectY = 50
dRectH = 14
dRectW = 14
strNameShort = "Horizontal Please"
Set shTextBox = Sheet1.Shapes.AddTextbox(msoTextOrientationHorizontal, dRectX, dRectY, dRectW, dRectH)
With shTextBox
.TextFrame.AutoSize = True
.TextFrame.Characters.Font.Size = 8
.TextFrame.Characters.Font.Bold = True
.TextFrame.Characters.Text = strNameShort
.Line.Visible = msoFalse
.Fill.Visible = msoFalse
End With
End Sub
A similar problem was discussed in this thread. Since the text in the textbox changes I cannot give an exact width for the text box. Thanks in advance. Sameer. Please use CODE tags rather than colour formatting the code. Last edited by Andy Pope; 07-16-2008 at 05:08 PM. |
|
#2
|
||||
|
||||
|
Autosize now works for the height so you need to resize and check the number of lines.
Code:
Sub PlotTBox()
Dim dRectX As Double, dRectY As Double, dRectW As Double, dRectH As Double
Dim dStartPos As Double
Dim shTextBox As Shape
Dim strNameShort As String
dRectX = 50
dRectY = 50
dRectH = 14
dRectW = 14
strNameShort = "Horizontal Please"
Set shTextBox = Sheet1.Shapes.AddTextbox(msoTextOrientationHorizontal, dRectX, dRectY, dRectW, dRectH)
With shTextBox
.TextFrame.AutoSize = True
.TextFrame.Characters.Font.Size = 8
.TextFrame.Characters.Font.Bold = True
.TextFrame.Characters.Text = strNameShort
.Line.Visible = msoFalse
.Fill.Visible = msoFalse
Do While .TextFrame2.TextRange.Lines.Count > 1
.Width = .Width + 2
.TextFrame.AutoSize = True
Loop
End With
End Sub
|
|
#3
|
|||
|
|||
|
Dear Andy,
Thank you for the quick reply and showing me the workaround. Much appreciated. Do you have any idea why this is happening , since the code runs fine in Excel 2003. Is it a bug? Had Microsoft announced this change?Things like this is very frustrating if you have to change this in several pages of code.Regards, Sameer |
|
#4
|
||||
|
||||
|
Shapes and charts are completely new in xl2007.
The autosize no longer auto sizes on both the height and width but only the height. It is not a bug as this is the new behaviour but it is a change. |
![]() |
| Bookmarks |
New topics in Excel 2007 Help
|
|
|
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|