Grouping and Creating a Texbox + A Shape VBA

ericmax79

New Member
Joined
Dec 13, 2013
Messages
37
[FONT=Verdana, serif]Helloguys[/FONT][FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]
Icould use a little help . I want to insert a box .....Then " Adda textbox "at the same time . Preferably i would like to groupit as well. So that when i move the rectangle the text box isattached to it . Could someone please help guide me . I am very newto vba and just staring out . I really want to group it upon itscreation u Know ....Thank you guys happy computing
[/FONT]
[FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]


EricMaxfield ....
[/FONT]
[FONT=Verdana, serif] [/FONT][FONT=Verdana, serif]

[/FONT]
Code:
[COLOR=#333333][FONT=Verdana, serif][SIZE=2]

SubDrawRect() '


Set myDocument = ActiveSheet

WithmyDocument.Shapes.AddShape(msoShapeRectangle, _
480, 170, 200,200)
.Name = "A"
.Fill.Visible =msoFalse
.Line.ForeColor.RGB = RGB(48, 48, 48)
.Line.DashStyle= msoLineSolid

.Line.Weight = 2.5


End With

EndSub[/SIZE][/FONT][/COLOR]
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can Mr Poulson . Unfortunately I don't know the value of The Text box yet . I want to make 2 objects "text Box " and "rectangle" with one "macro" then group them so that the user can move the "rectangle and the "text " box follows . Or has the same movement as the Rectangle .
 
Upvote 0
That it is . I can use your solution for the "rectangle .Thank you very much . Mr Poulsom I need it for a line as well . A connector line . I will send you the code .
 
Upvote 0
I would like to create a "text Box " with that command . A box that "binds" well "groups" with that connector Line I create . Thank yo uso much for your time . And your answer to my Other thread . Much Appreciated . I would like it to group so that the user can drag the line connector around and the Text box would follow it accordingly .



Code:
Sub N_Click()
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 400, 250, 800, 250).Select
Selection.ShapeRange.Line.BeginArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadShort
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadStealth
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadNarrow
Selection.ShapeRange.Line.Weight = 2.5
Selection.ShapeRange.Line.ForeColor.RGB = RGB(139, 0, 139)
Selection.Name = "N"
 
Upvote 0
Try:

Code:
Sub Test()
    Dim TB As Shape
    Dim Conn As Shape
    With ActiveSheet
        Set TB = .Shapes.AddTextbox(msoTextOrientationHorizontal, 480, 170, 200, 200)
        Set Conn = .Shapes.AddConnector(msoConnectorStraight, 400, 250, 800, 250)
        With Conn
            With .Line
                .BeginArrowheadLength = msoArrowheadShort
                .BeginArrowheadStyle = msoArrowheadStealth
                .BeginArrowheadWidth = msoArrowheadNarrow
                .EndArrowheadLength = msoArrowheadShort
                .EndArrowheadStyle = msoArrowheadStealth
                .EndArrowheadWidth = msoArrowheadNarrow
                .Weight = 2.5
                .ForeColor.RGB = RGB(139, 0, 139)
            End With
            .Name = "N"
        End With
        .Shapes.Range(Array(TB.Name, Conn.Name)).Group
    End With
End Sub
 
Upvote 0
Wow .... Your My idol .... :) I have other Problems I probably Have used up my "daily Credit"


Thank you So much .
Absolutely it Works !
 
Upvote 0
May I send one more your Way Sir ? Im so excited now . I have been trying to do this for days . This is my @nd week in VBA only :)
 
Upvote 0
I would like to "group" all these shapes .........Not Select them ... This Command Selects them All.... Thats as far as my Skills have got Me Thus Far .
Rich (BB code):
[FONT=Verdana, serif]SubSelectAll_Click()
Dim Shp As Shape

For Each Shp InActiveSheet.Shapes
If Not (Shp.Type = msoOLEControlObject OrShp.Type = msoFormControl) Then Shp.Select All
Next Shp


EndSub[/FONT]
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top