利用VBA批量替换PPT中图例的文字内容
批量将PPT中图表的文字内容进行替换,自带的查找替换只能替换正文内容 有大神不?求教 @weiyingde,老师,求教 Sub ReplaceText()Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="华东", _
Replacewhat:="huadong", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="华东", _
Replacewhat:="huadong", WholeWords:=True)
Loop
Next oShp
End Sub
这个运行没实现 这是样本
Sub ReplaceText()
Dim Sd As Slide, Wk As Object, Rng, Rp
Set Sd = ActivePresentation.Slides(1)
'图形中的工作簿对象
Set Wk = Sd.Shapes(3).Chart.ChartData.Workbook
'工作簿中的工作表数据范围
Set Rng = Wk.WorkSheets(1).Range("A1:N3")
'执行替换操作
Rp = Rng.Replace("北方", "BeiFang", 1)
End Sub
页:
[1]