LoginSignup
1
1

More than 5 years have passed since last update.

[PowerPoint VBA]コンマを全消しするマクロ(Replaceの使用例)

Posted at

PowerPointとPublisherは似ているが...

[PowerPoint VBA] コンマを全消しするマクロ (Replaceの使用例)を作ってみたのでこれをPowerPointで実行するマクロです。

Sub ppDeleteCommas()
'For PowerPoint VBA
Dim ppP As PowerPoint.Presentation
Dim sh As PowerPoint.Shape, shs As PowerPoint.Shapes
Dim sld As PowerPoint.Slide, slds As PowerPoint.Slides
Dim tFrame As PowerPoint.TextFrame, tRng As PowerPoint.TextRange
Dim FoundRng As TextRange
Set ppP = ActivePresentation
Set slds = ppP.Slides
For Each sld In slds
Set shs = sld.Shapes
For Each sh In shs
If sh.HasTextFrame Then
Set tFrame = sh.TextFrame
Set tRng = tFrame.TextRange
Do
Set FoundRng = tRng.Find(FindWhat:=",", After:=1)
If Not FoundRng Is Nothing Then
tRng.Replace FindWhat:=",", ReplaceWhat:="", MatchCase:=msoFalse, wholewords:=msoFalse
Else
Exit Do
End If
Loop
End If
Next
Next
End Sub

Publisherとの相違点

  • DocumentではなくPresentationになる(当たり前ですね)
  • Pageではなくスライドになる(これも当然でしょう)
  • そこからShape-Textrangeへもっていく方法はよく似ている。
  • 置換は1行でかける。
  • あいまい検索が使える。
  • この書き方はPowerPointの置換のたぶん基本
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1