0

我正在尝试复制 Powerpoint 2007 中“查找”按钮的行为。我已经能够编写 vba 来查找我正在搜索的文本,但我想将包含文本的形状带到主要的中心窗户。我的代码选择了正确的幻灯片和形状,只是不可见。

ppt.Presentations.open(strFloorPlan)
For each sld in ppt.Activepresentation.Slides
    For each shp in sld.shapes
        if shp.hasTextFrame then
            set txtrng =  shp.textFrame.TextRange
            set foundtext =txtrnd.Find(findwhat:="A string representing my search criteria)
            do while not (foundtext is nothing)
                sld.select      'This works
                shape.select    'This works

             **At this point I have my text selected, but is off screen. I would like                  it to be in the current ppt window, so the users do not net to find it.**

            Loop
         End if
     Next
Next
4

2 回答 2

1

这会让你接近:

ActiveWindow.ScrollIntoView shp.Left, shp.Top, shp.Width, shp.Height

它确保由您提供的坐标(即形状的坐标)界定的区域完全在视图中。但是,它不会在当前视图中居中形状。

于 2013-08-19T13:49:14.477 回答
0

添加以下内容以将您的搜索找到的形状位置更改为屏幕中心(前提是形状小于演示文稿):

shp.Top = (ActivePresentation.PageSetup.SlideHeight - shp.Height) / 2
shp.Left = (ActivePresentation.PageSetup.SlideWidth - shp.Width) / 2
于 2013-08-19T06:42:23.737 回答