VBA 将所有 powerpoint 文本框设置为选项 "Shrink text on overflow" 的代码
VBA code to set on all powerpoint textboxes to the option "Shrink text on overflow"
我正在搜索一个 VBA 代码,它可以为 PowerPoint 文档中的所有文本框激活选项“溢出时收缩文本”。我试过了:
Sub Change()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
oShape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape
Next oShape
Next oSlide
End Sub
但不幸的是,这不起作用。我是初学者。
有什么想法吗?
谢谢。
只需使用 msoAutoSizeTextToFitShape 而不是 MsoAutoSize.msoAutoSizeTextToFitShape。最好先检查形状是否真的有文本框。此版本也在组内获取形状:
Sub Change()
Dim oSlide As Slide
Dim oShape As Shape
Dim oSubShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
For Each oSubShape In oShape.GroupItems
If oSubShape.HasTextFrame Then
oSubShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
End If
Next oSubShape
Else
If oShape.HasTextFrame Then
oShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
End If
End If
Next oShape
Next oSlide
End Sub
我正在搜索一个 VBA 代码,它可以为 PowerPoint 文档中的所有文本框激活选项“溢出时收缩文本”。我试过了:
Sub Change()
Dim oSlide As Slide
Dim oShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
oShape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape
Next oShape
Next oSlide
End Sub
但不幸的是,这不起作用。我是初学者。
有什么想法吗?
谢谢。
只需使用 msoAutoSizeTextToFitShape 而不是 MsoAutoSize.msoAutoSizeTextToFitShape。最好先检查形状是否真的有文本框。此版本也在组内获取形状:
Sub Change()
Dim oSlide As Slide
Dim oShape As Shape
Dim oSubShape As Shape
For Each oSlide In ActivePresentation.Slides
For Each oShape In oSlide.Shapes
If oShape.Type = msoGroup Then
For Each oSubShape In oShape.GroupItems
If oSubShape.HasTextFrame Then
oSubShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
End If
Next oSubShape
Else
If oShape.HasTextFrame Then
oShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
End If
End If
Next oShape
Next oSlide
End Sub