Created
February 26, 2025 16:19
-
-
Save Endermanbugzjfc/a7923a9d64f286840ec6928c9ae30104 to your computer and use it in GitHub Desktop.
Personal VBA macro that replace specific words in PowerPoint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Ans() | |
For Each Slide In ActivePresentation.Slides | |
For Each Shape In Slide.Shapes | |
If Shape.HasTextFrame Then | |
Set A = Shape.TextFrame.TextRange.Find(FindWhat:="Answer: ") | |
If Not A Is Nothing Then | |
Shape.TextFrame.TextRange.Text = "Answer: ___" | |
End If | |
End If | |
If Shape.HasTextFrame Then | |
Set E = Shape.TextFrame.TextRange.Find(FindWhat:="Explanation: ") | |
If Not E Is Nothing Then | |
Shape.TextFrame.TextRange.Text = "Explanation..." | |
End If | |
End If | |
Next | |
Next | |
End Sub | |
Sub AnsZh() | |
Dim APlaceholder As String | |
APlaceholder = ChrW(31572) & ChrW(26696) & ChrW(65306) | |
Dim EPlaceholder As String | |
EPlaceholder = ChrW(38988) & ChrW(35299) & ChrW(65306) | |
For Each Slide In ActivePresentation.Slides | |
For Each Shape In Slide.Shapes | |
If Shape.HasTextFrame Then | |
Set A = Shape.TextFrame.TextRange.Find(FindWhat:="Answer: ") | |
If Not A Is Nothing Then | |
Shape.TextFrame.TextRange.Text = "Answer: ___" | |
End If | |
End If | |
If Shape.HasTextFrame Then | |
Set E = Shape.TextFrame.TextRange.Find(FindWhat:="Explanation: ") | |
If Not E Is Nothing Then | |
Shape.TextFrame.TextRange.Text = "Explanation..." | |
End If | |
End If | |
If Shape.HasTextFrame Then | |
Set A = Shape.TextFrame.TextRange.Find(FindWhat:=APlaceholder) | |
If Not A Is Nothing Then | |
Shape.TextFrame.TextRange.Text = APlaceholder & "_" | |
End If | |
End If | |
If Shape.HasTextFrame Then | |
Set E = Shape.TextFrame.TextRange.Find(FindWhat:=EPlaceholder) | |
If Not E Is Nothing Then | |
Shape.TextFrame.TextRange.Text = EPlaceholder & "......" | |
End If | |
End If | |
Next | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment