Scott Helmers
asked on
change font in PPT text box from VBA
I'm trying to change the font of an empty text placeholder on a slide from VBA. Sounds simple enough but apparently I haven't got the right object or something...
I've tried a variety of approaches including the ones shown below. Test1 (textrange object) and Test2 (shape object) didn't work. Then I used the macro recorder to record the UI actions that do accomplish what I want. However, replaying this macro does *not* cause the correct result.
What am I missing?
Thanks
I've tried a variety of approaches including the ones shown below. Test1 (textrange object) and Test2 (shape object) didn't work. Then I used the macro recorder to record the UI actions that do accomplish what I want. However, replaying this macro does *not* cause the correct result.
What am I missing?
Thanks
Sub test1()
Dim tr As TextRange
Set tr = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange
tr.Font.Size = 18
End Sub
Sub test2()
Dim shp As Shape
Set shp = ActivePresentation.Slides(1).Shapes(2)
shp.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Font.Size = 18
End Sub
Sub Macro12()
ActiveWindow.Selection.SlideRange.Shapes("Rectangle 21").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Font.Size = 18
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Very, strange, isn't it? Add it to the list of oddities that one needs to track to make VBA do what you think it should do in the Office products. :)
ASKER
Thanks for the suggestion. It did work! So PPT doesn't like setting fonts on empty textranges from code even though it works in the UI...