0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【PowerPointVBA】選択中shpの中身を同名shpに展開する

Last updated at Posted at 2022-03-10

今作ってるxl→pp転記マクロの実行後に手直ししたいときに作ったやつ。

テキストボックスを選択中に実行すると、全スライドを巡回して同名のシェイプ名の中身にコピペしまくる。

転記のアンカーに使ってたシェイプ名をpp単体でもアンカーとして使いまわすだけなので楽。

' ==========================================
' ここから pp選択中shpの中身を同名shpに展開する
' ==========================================
Sub pp選択中shpの中身を同名shpに展開する()
  Dim myShp As String, myStr As String
  myShp = Get選択中Shp
  myStr = Get選択中Shpのテキスト
  
  Dim sld As PowerPoint.Slide
  Dim shp As PowerPoint.Shape
  
  For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes
      If shp.Name = myShp Then
        shp.TextFrame.TextRange.Text = myStr
        Exit For
      End If
    Next
  Next

End Sub

Function Get選択中Shp() As String
  With ActiveWindow.Selection
    If .Type >= ppSelectionShapes Then
      Get選択中Shp = .ShapeRange.Name
    End If
  End With
End Function

Function Get選択中Shpのテキスト() As String
  With ActiveWindow.Selection
    If .Type >= ppSelectionShapes Then
      Get選択中Shpのテキスト = .ShapeRange.TextFrame.TextRange.Text
    End If
  End With
End Function

' ==========================================
' ここまで pp選択中shpの中身を同名shpに展開する
' ==========================================

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?