実行コード
Sub a()
Call Set選択されている図形の名前("test")
End Sub
Sub b()
Call 指定された名前の図形にテキストデータ書き込み("test", "内容")
End Sub
Sub c()
Call 指定された名前の図形にテキストデータ読み込み("test")
End Sub
図形の名前の設定/取得
Sub Get選択されている図形の名前()
Dim shp As Shape
With ActiveWindow.Selection
If .Type = ppSelectionNone Or _
.Type = ppSelectionSlides Then Exit Sub
For Each shp In .ShapeRange
Debug.Print shp.Name
Next shp
End With
End Sub
Sub Set選択されている図形の名前(ShapeName)
Dim shp As Shape
With ActiveWindow.Selection
If .Type = ppSelectionNone Or _
.Type = ppSelectionSlides Then Exit Sub
For Each shp In .ShapeRange
shp.Name = ShapeName
Next shp
End With
End Sub
指定名の図形を狙って読み書き
Sub 指定された名前の図形にテキストデータ書き込み(ShapeName, 書き込む内容)
Dim prs As Presentation
Dim sld As Slide
Dim shp As Shape
Set prs = PowerPoint.ActivePresentation
For Each sld In prs.Slides
Debug.Print sld.Name
For Each shp In sld.Shapes
If shp.Name = ShapeName Then
shp.TextFrame.TextRange.Text = 書き込む内容
End If
Next
Next
End Sub
Sub 指定された名前の図形にテキストデータ読み込み(ShapeName)
Dim prs As Presentation
Dim sld As Slide
Dim shp As Shape
Set prs = PowerPoint.ActivePresentation
For Each sld In prs.Slides
Debug.Print sld.Name
For Each shp In sld.Shapes
If shp.Name = ShapeName Then
Debug.Print shp.TextFrame.TextRange.Text
End If
Next
Next
End Sub