MS Excel 2007 - SHAPES - Select whole group with grouped textboxes, instead of textbox in group.

הצעה לתשובה MS Excel 2007 - SHAPES - Select whole group with grouped textboxes, instead of textbox in group.

  • 2012年3月21日 9:20
     
     

    Hello,

     

    I have added different textboxes and shapes into a group in MS Excel 2007.

    When I want to select the whole group of shapes I have to click outside the "textbox shape" area otherwise it wil select only the textbox shape in the group.

    My problem is that my whole group is the "textbox shape"area. And i want to select the whole group when clicking on it.

    Does anybody know a solution for this problem? In settings or VBA code?

    Thanks in advance,

     

    Vincent

すべての返信

  • 2012年3月21日 9:28
     
     

    Does it make it easier to select the required item(s) if you use the Selection Pane.

    Home tab > Editing > Find & Select > Selection Pane.


    Cheers,

    Andy
    www.andypope.info

  • 2012年3月21日 10:48
     
     

    Nope, it does not.

    It makes no difference.

  • 2012年3月21日 11:27
    回答者:
     
     

    Not Sure what you need but following will select all the shape in Activesheet.

    ActiveSheet.Shapes.SelectAll

  • 2012年3月23日 0:32
    モデレータ
     
     回答の候補 コードあり

    Three ways I can think of

    1) Selecting on the main border


    2) Typing the Group Name in the "Name Box"


    3) VBA

    Sub Sample()
        '~~> Change this to the relevant Group
        Sheets("Sheet1").Shapes("Group 4").Select
    End Sub

    HTH


    Sid (A good exercise for the Heart is to bend down and help another up) Please do not email me your questions. I do not answer questions by email unless I get paid for it :) If you want, create a thread in VB.Net/Excel forum and email me the link and I will help you if I can.

  • 2012年3月23日 8:49
     
     

    You are right, on all three ways you select the whole group.

    But still not an answer to my question: " I want to select the whole group when clicking on it".

    I found out that pressing the control button before clicking on the group does select the whole group, so that's a work around, but I think it should be possible to programm it in a way that it selects the group automatically when clicking on it.



  • 2012年4月11日 15:29
     
     

    I have a slightly different problem but I believe the same answer could help both me and Vincent.

    Is there a way of determining the name of the group that a clicked shape belongs to?

    Vincent could then use this to help him utilise Siddharth Rout's sample code and I could use it for my purpose, which is to delete the group when a little red rectangle in the the top right corner of the group is clicked.

    Br,   Nick.


    Edit: I should add that in my case I won't know the name of the group because multiple copies of the sheet containing this group may be created within the workbook. Also this is not the only group of shapes to exist on the sheet.
    • 編集済み onimoD XLT 2012年4月11日 16:09 Clarity
    •  
  • 2012年4月12日 9:43
     
     回答の候補

    Hi Vincent,

    I believe I have your answer. Don't use textboxes, i.e. use rectangles instead and edit their text property. You should then find that one click selects the whole group.

    Br,   Nick.

    • 回答の候補に設定 onimoD XLT 2012年4月12日 9:44
    •  
  • 2012年4月12日 9:58
     
     

    Okay I've solved my problem but for completeness and so that it might help someone else I'll put my solution here...

    Basically I have three groups - little helper texts like the one above - which get propogated each time the user creates a certain type of sheet (which is a copy from a hidden template sheet). The group names get incremented each time but the individual shape names remain constant i.e. Group names appear to have a scope of 'Workbook' while shape names have a scope of 'Sheet'.

    The red delete buttons have been named DelButton1, DelButton2 and DelButton3 and each is assigned to the macros DelGrp1, 2 and 3 respectively...

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Public Sub DelGrp1()
        DeleteGroup (1)
    End Sub

    Public Sub DelGrp2()
        DeleteGroup (2)
    End Sub

    Public Sub DelGrp3()
        DeleteGroup (3)
    End Sub

    Private Sub DeleteGroup(ByVal aNum As Long)
        Dim shp As Shape
        Dim grp As Shape

        For Each grp In ActiveSheet.Shapes
            If grp.Name Like "Group*" Then
                For Each shp In grp.GroupItems
                    If shp.Name = "DelButton" & aNum Then
                        grp.Delete
                        Exit Sub
                    End If
                Next
            End If
        Next
    End Sub

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I hope someone finds this useful.

    Br,   Nick.