2016-08-09 1 views
0

こんにちは、私は(下左)、セルコーナーD12に動的に図形を追加する必要が は、ここでは、この結果に私のコードセルの隅にAddshape

Set textRectangle = ActiveSheet.Shapes.AddShape(msoShapeOval, Range("D13").Left, Range("D13").Top, 20, 20) 

textRectangle.name = "test shape" 
' add your text 
textRectangle.TextFrame.Characters.Text = "Your" 

' fill the shape with the rgb color of your choice 
textRectangle.Fill.ForeColor.RGB = RGB(220, 105, 0) 

です:enter image description here

、ここでは私がしたい結果ですそれは

答えて

0

私が目だと思い、私が作成した後に円をreshappingい enter image description here

を持っていますそれを追加するときにもシェイプの半径を考慮する必要があるかもしれません。

コード:(今後の参考のため)また

Sub add_shape() 

    Dim textRectangle As Shape 
    Dim radius As Integer 
    radius = 20 
    Set textRectangle = ActiveSheet.Shapes.AddShape(msoShapeOval, (Range("D13").Left - radius/2), _ 
         Range("D13").Top - radius/2, radius, radius) 

End Sub 

、あなたが他のオブジェクトの操作のためRange("A1").WidthRange("A1").Height性質を利用することができます:)

HTH;)

+0

あなたに感謝助けて、私はそれを試して、それはコーナーの中心にはない、私は何かが欠けている? – BKChedlia

+0

書いたコードを投稿できますか? – RCaetano

+0

私はあなたのコードを試してみたが、混乱しているコードを試しましたが、良いポジションを与えてくれました:set textRectangle = ActiveSheet.Shapes.AddShape(msoShapeOval、(Range( "D12")。Left) - 10、(Range( "D12 ").Top)+ 89、10、10) – BKChedlia