Question

I am creating a text box using vba in powerpoint. For that I am using the following code:

Set survey = cSlide.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 40, 400, 20)
    survey.TextFrame.TextRange.text = Me.QuestionBox.text


        survey.TextFrame.TextRange.font.SIZE = sh.GroupItems(1).TextFrame.TextRange.font.SIZE
        survey.TextFrame.TextRange.font.name = sh.GroupItems(1).TextFrame.TextRange.font.name
        survey.width = sh.GroupItems(1).width
        survey.height = sh.GroupItems(1).height
        survey.top = sh.GroupItems(1).top
        survey.left = sh.GroupItems(1).left

As you can notice I am using the size of another shape to make it the same size as it. This is how the shape that I am using (above) and I created (below) looks:

enter image description here

I want it to appear in 2 lines instead of one. You can see that the width and height is correct but instead of going to the second line when it reach to the border of the shape it continues. If you just modify manually the shape below and give a bit more or less width it automatically put the second word in the second line but I cannot make it happen when I do it with vba. Is there something I can use to make it happen automatically?

Was it helpful?

Solution

When you add new shape to the slide, your shape default settings may be preventing wordwrap.

Please try:

survey.TextFrame.WordWrap = msoTrue

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top