Determining if a powerpoint text box is over the p

2019-09-11 00:21发布

I've been researching this for a while and have not found any background on whether Powerpoint VBA can determine if an object (text box or table) is outside the bounds of the page dimensions.

The specific application I am trying to manage is when I flow text into a PPT table from Excel, through a find/replace of specific data markers, I don't know the specific dimensions of the text, so I may overflow the page boundary.

I cant shrink the text either, as I have to maintain the design fidelity of the type size.

I would like to try and measure when this overflow happens and use VB to create a new page onto which I can continue to flow my text from Excel.

Right now I am doing this by just limiting the page template to say 15 rows and then manually adjusting over/under flow of the page. Might be my only option, but thought I would pose the question.

1条回答
疯言疯语
2楼-- · 2019-09-11 00:56

This should get you started:

Option Explicit

Sub TextboxCheck()

Dim shp As Shape
Dim sld As Slide
Dim sldHeight As Long

sldHeight = ActivePresentation.PageSetup.SlideHeight

For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes
        If shp.Type = msoTextBox Then
            If shp.Top + shp.Height > sldHeight Then
                'Add your code here for moving the text to a new slide
            End If
        End If
    Next shp
Next sld

End Sub
查看更多
登录 后发表回答