Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PowerPoint 2010 VBA how to set the text justification to left in a TextFrame2? 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Nothing seems to work, I set the properties below and get error
Code:
Private Sub DrawBoxSubOrdinate(MyDocument, FullName, DataInBox, Left, Top, ShapeWidth, ShapeHeight, FontSize, TheColor)
    'draws a box and puts text in it at the location
    With MyDocument.Shapes.AddShape(msoShapeRectangle, _
          Left, Top, ShapeWidth, ShapeHeight)
          .Fill.Visible = msoFalse
          .Name = FullName
          .Line.Visible = msoFalse
          .TextFrame2.TextRange.Text = DataInBox
         [highlight #FCE94F] '.TextFrame2.HorizontalAlignment = xlHAlignCenter[/highlight]         
          '.TextFrame2.VerticalAlignment = xlVAlignCenter
          '.TextFrame2. ????
          With .TextFrame2.TextRange.Font
             .Name = "Arial"
             .Size = FontSize
             '.Bold = msoFalse
             Select Case TheColor
                Case "Blue"
                    .Fill.ForeColor.RGB = RGB(0, 0, 255)
                Case "Black"
                    .Fill.ForeColor.RGB = RGB(0, 0, 0)
                Case "Green"
                    .Fill.ForeColor.RGB = RGB(0, 255, 0)
                Case Else
                    .Fill.ForeColor.RGB = RGB(0, 0, 0) ' black in case the color is empty
             End Select
             
             [highlight #FCE94F]'.HorizontalAnchor = msoAnchorNone[/highlight]         
   End With
   End With
End Sub
    


DougP
 
hi,

If you are in PowerPoint, why are you using Excel Constants like xlHAlignCenter. Open your Object Browser and find the proper constant.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
OK I found this for Powerpoint but there is still no "LEFT"

.TextFrame2.HorizontalAnchor = msoAnchorNone
just these
msoAnchorBottom
msoAnchorBottomBaseline
msoAnchorCenter
msoAnchorMiddle
msoAnchorNone
msoAnchorTop
msoAnchorTopBaseLine
is there something else I need?

DougP
 
this worked for me
Code:
    With ActivePresentation
        With .Slides(1)
           with .Shapes(1)
            .TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
           end with
        End With
    End With

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you Skip
I have no idea why its stuck under ParagraphFormat or how you found it?

DougP
 
I went to the slide. All the Alignments are in a Paragraph group.

So then, using faq707-4594, I 'discovered' the object heirarchy to the Paragraph object, and the rest is history.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top