'テキストボックスを作成して、文字を入れる例です。
Sub テキストボックス作成()
With ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 10, 10, 70, 24)
.TextFrame.Characters.Text = "VBAヒント"
End With
End Sub
'「VBA」という名前のテキストボックスの色を変更する例です。
Sub テキストボックス色変更()
With ActiveSheet.Shapes("VBA")
'背景を紫色にする
.Fill.ForeColor.RGB = RGB(255, 0, 255)
'縁の線を黄色にする
.Line.ForeColor.RGB = RGB(255, 255, 0)
End With
End Sub
'「VBA」という名前のテキストボックスを下へ10ポイント移動する例です。
Sub テキストボックス移動()
ActiveSheet.Shapes("VBA").IncrementTop 10
End Sub
'「VBA」という名前のテキストボックスのサイズを変更する例です。
Sub テキストボックスサイズ変更()
With ActiveSheet.Shapes("VBA")
.Width = 200
.Height = 50
End With
End Sub
'「VBA」という文字が入力されているテキストボックスを選択する例です。
Sub テキストボックス選択()
Dim S As Shape
For Each S In ActiveSheet.Shapes
'テキストボックスであるかどうか検査
If S.Type = msoTextBox Then
If S.TextFrame.Characters.Text = "VBA" Then
S.Select False
End If
End If
Next S
End Sub