Skip to content

Instantly share code, notes, and snippets.

@ozero
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozero/8999202 to your computer and use it in GitHub Desktop.
Save ozero/8999202 to your computer and use it in GitHub Desktop.
Powerpoint vba AutoSize_Example. For all TextShapes in all slides, all presentation windows, shrink font size to fit with textbox.
' mod from msdn http://msdn.microsoft.com/en-us/library/office/ff744773.aspx
Public Sub AutoSize_Example()
Dim prs As Presentation
Dim pptSlide As Slide
For Each prs In Presentations
Debug.Print prs.Name
For Each pptSlide In prs.Slides
For i = 1 To pptSlide.Shapes.Count Step 1
Set Shape = pptSlide.Shapes(i)
If Shape.HasTextFrame Then
'TODO: check AltTxt here
' http://msdn.microsoft.com/en-us/library/office/ff744026.aspx
Set tf2 = Shape.TextFrame2
Debug.Print tf2.TextRange.Characters
If tf2.TextRange.Characters.Count < 50 Then
tf2.AutoSize = msoAutoSizeTextToFitShape
End If
End If
Next
Next pptSlide
Next prs
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment