如何在不更改格式的情况下更新PPT文本框中的内容
How do I update content in PPT textbox while not changing the format
嘿,我正在做一个报告生成程序。
我需要更新 PowerPoint 中某些文本框的某些部分(例如日期)。
我试着用vba来做,但结果很复杂,因为一旦我更新了文本内容,我就必须重新设置所有格式。
有没有方便的方法来更新 TextBox 的某些部分而无需重新设置所有格式?
如您所料,Replace 方法将执行您想要的操作。
示例:
Sub ReplaceText(oRng As TextRange, sReplaceWhat As String, sWithWhat As String)
With oRng
.Characters.Replace sReplaceWhat, sWithWhat
End With
End Sub
并对其进行测试
Sub Test()
With ActivePresentation.Slides(1).Shapes(1)
Call ReplaceText(.TextFrame.TextRange, "text", "newtext")
End With
End Sub
嘿,我正在做一个报告生成程序。
我需要更新 PowerPoint 中某些文本框的某些部分(例如日期)。
我试着用vba来做,但结果很复杂,因为一旦我更新了文本内容,我就必须重新设置所有格式。
有没有方便的方法来更新 TextBox 的某些部分而无需重新设置所有格式?
如您所料,Replace 方法将执行您想要的操作。
示例:
Sub ReplaceText(oRng As TextRange, sReplaceWhat As String, sWithWhat As String)
With oRng
.Characters.Replace sReplaceWhat, sWithWhat
End With
End Sub
并对其进行测试
Sub Test()
With ActivePresentation.Slides(1).Shapes(1)
Call ReplaceText(.TextFrame.TextRange, "text", "newtext")
End With
End Sub