#contents
*Excel 関連情報 [#i955dbea]
**サンプルコード [#r906d104]
***シート内のテキストボックスの文字列を置換するサンプル [#o591bd0b]
 ' メインプロシージャ
 Sub Main()
     ReplaceTextBox "aaa", "bbb" ' "aaa" を "bbb" に置換する。
 End Sub
 
 ' テキストボックスの文字列の置換を行うプロシージャ
 Sub ReplaceTextBox(ByVal strFind, ByVal strReplace)
      ' 複数シートに対して処理を行う
      Dim sheet
      For Each sheet In Worksheets
          ' 各オートシェイプに対して処理を行う
          Dim shape
          For Each shape In sheet.Shapes
             ' タイプがテキストボックスの場合にのみ置換処理を行う
             If shape.Type = msoTextBox Then
                 Dim strOld
                 Dim strNew
                 ' 現在のテキストボックスの文字列を取得
                 strOld = shape.TextFrame.Characters.Text
                 strNew = Replace(strOld, strFind, strReplace)
                 ' 新しい文字列をテキストボックスにセット
                 shape.TextFrame.Characters.Text = strNew
             End If
          Next
      Next
 End Sub

-はてな
--http://www.hatena.ne.jp/1089615935

//#comment


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS