Howdy,
I've got a function that creates a textbox on a PowerPoint slide and then adds a string of text that's been passed into it to the slide.
My problem is that when I programatically create textboxes, the text inside is always going downward, even though it has the Orientation property set to horizontal. As soon as I manually resize the textbox it reflows correctly, but it apparently ignores all my alignment and sizing details.
Below is an anonymized screenshot (click for big) of the behavior I'm talking about. Any ideas on how I can resolve this? It doesn't seem to matter how I set my sizing, only the alignment information in the function is taken into effect, although by checking break-points everything seems to be registering in the VBA.
Thanks.
I've got a function that creates a textbox on a PowerPoint slide and then adds a string of text that's been passed into it to the slide.
Code:
Public Function copy_text(sheet As String, textString As String, slide As Integer, awidth As Integer, aheight As Integer, atop As Integer, aleft As Integer)
Sheets(sheet).Select
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
PPApp.ActiveWindow.View.GotoSlide (slide)
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
'Create textbox and populate it
PPSlide.Shapes.AddTextbox msoTextOrientationHorizontal, aleft, atop, awidth, aheight
With PPSlide.Shapes(PPSlide.Shapes.Count).TextFrame.TextRange
.text = textString
.Font.Size = 40
.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter
End With
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Function
Below is an anonymized screenshot (click for big) of the behavior I'm talking about. Any ideas on how I can resolve this? It doesn't seem to matter how I set my sizing, only the alignment information in the function is taken into effect, although by checking break-points everything seems to be registering in the VBA.
Thanks.