【发布时间】:2017-05-30 12:06:07
【问题描述】:
我正在尝试为 VBA 中的 Power Point 幻灯片编写 batch find and replace 代码,但出现以下错误:Compile Error Method or data member not found。
调试器正在突出显示 PP.Shapes 在线 13 中的形状。
我对VBA没有太多经验。我从以下方面收集了想法:
* Getting Started with VBA in PowerPoint 2010 (Office 开发中心)
* Power Point VBA-Find & Replace (YouTube)
* “从文件导入幻灯片的简单宏”@(VBA Express 论坛)
Sub BatchFindReplace()
Dim shp As Shape
Dim strFileName As String
Dim strFolderName As String
Dim PP As Presentation
'Directory
strFolderName = "C:\Users\Emma\Desktop\temp1"
strFileName = Dir(strFolderName & "\*.ppt*")
Do While Len(strFileName) > 0
Set PP = Presentations.Open(strFolderName & "\" & strFileName)
'Find and Replace Code
For Each shp In PP.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "W", "kkk")
End If
End If
Next
PP.Close
strFileName = Dir
Loop
End Sub
【问题讨论】:
-
VBA标签将涵盖所有 MS-Office 应用程序。您不必标记所有这些 :) -
哦,好的,我明白了:)。
标签: vba powerpoint