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?

Excelのオブジェクト(Shape)のテキストを取得・変更する方法(VBA)

Posted at

Excelで図形(Shape)のテキストを取得・変更するVBAサンプルです。

サンプルコード

例えば、ワークシート「Sample」上にある図形(Shape)で、テキストが「重要」となっているものを「【重要】」に書き換える場合は、次のように記述します。

Dim s As Shape
For Each s In ThisWorkbook.Worksheets("Sample").Shapes
    If s.TextFrame.Characters.Text = "重要" Then
        s.TextFrame.Characters.Text = "【重要】"
    End If
Next s

ポイント

  • Shapesコレクションを使って、ワークシート上の全ての図形(Shape)を取得できます。
  • 各Shapeのテキストは、TextFrame.Characters.Text で参照・変更できます。
  • 条件に合致したテキストだけを書き換えることが可能です。

動作環境

  • Microsoft Visual Basic for Applications 7.1
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?