| 
    
     |  | ▼roki さん: こんばんは。
 
 >はじめまして。
 >駆け出しのVBA初心者のrokiと申します。
 >テキストボックスについて質問なのですが、
 >図形描画ツールバーのテキストボックスの作成と同じ
 >処理で線無しのものを作成するマクロの作成の仕方を
 >どなたかご存知ありませんか。
 >テキストボックスはマウスをドラッグして作画したいです。
 >オートシェイプの規定値としては線ありでマクロ実行時
 >のみ線無しのテキストボックスを作成したいのですが・・・
 「セル範囲を選択してマクロを実行すると選択したセル範囲にテキストボックスを線無しで作成する」なら、
 '===============================================
 Sub samp1()
 Dim txt As Shape
 Dim rng As Range
 Set rng = Selection
 With rng
 Set txt = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, .Left, .Top, .Width, .Height)
 txt.Line.Visible = msoFalse
 End With
 End Sub
 
 でいいと思うのですが、roki さんが考えている事は違うのでしょうね!!
 
 以下のマクロで何となく、それらしく動いています。
 
 Thisworkbookのモジュールに
 
 '================================================================
 Private WithEvents cmd As CommandBarButton
 Private click_flg As Long
 '================================================================
 Sub sample()
 With ActiveSheet
 cnt = .Shapes.Count
 click_flg = 0
 Set cmd = Application.CommandBars("Drawing").Controls(9)
 Application.CommandBars("Drawing").Controls(9).Execute
 Do Until (.Shapes.Count = cnt + 1) Or click_flg >= 2
 DoEvents
 Loop
 If .Shapes.Count = cnt + 1 Then
 .Shapes(.Shapes.Count).Line.Visible = msoflse
 End If
 End With
 Set cmd = Nothing
 End Sub
 '========================================================================
 Private Sub cmd_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
 click_flg = click_flg + 1
 End Sub
 
 
 「Thisworkbook.sample」を実行してみて下さい。
 
 ただ、不安定なところもあります。
 テキストボックス作成範囲を選択中は、コマンドバーのいくつかのコマンドボタンの
 表示が非表示状態になってしまいます(実際にクリックすることはできますが)。
 
 
 確認してみて下さい。
 
 
 |  |