LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default check whether shape is a group

FYI: Your original code worked just fine for me: I tested this by groupin
subgroups of controls together with pictures etc, and it did just what it was
supposed to do.

"Peter T" schrieb:

Hi Jim,

Yes that would work providing each Group only contained Form controls, and
not some other shape type. If any possibility that's not the case would need
to add an extra check before returning .FormControlType -

If shpRng(N).Type = msoFormControl Then

'Some other' shape type might be another sub-group! If so would mean
something recursive along the lines of my first post or a Do Loop.

Regards,
Peter T

"Jim Cone" wrote in message
...
Peter,
This seems to be working for me .
Regards
Jim Cone

'------------------------------
Sub SetButtonValues()
Dim Shp As Excel.Shape
Dim shpRng As Excel.ShapeRange
Dim arrShps() As Variant
Dim x As Long
Dim N As Long

For Each Shp In ActiveSheet.Shapes
If Shp.Type = msoGroup Then
x = Shp.GroupItems.Count
ReDim arrShps(1 To x)
For N = 1 To x
arrShps(N) = Shp.GroupItems(N).Name
Next
Shp.Ungroup
Set shpRng = ActiveSheet.Shapes.Range(arrShps)

For N = 1 To x
If shpRng(N).FormControlType = xlCheckBox Or _
shpRng(N).FormControlType = xlOptionButton Then
MsgBox shpRng(N).Name & " Value is " &

shpRng(N).ControlFormat.Value
End If
Next
shpRng.Regroup
End If
Next
End Sub
'--------------

"Peter T" <peter_t@discussions
wrote in message
The OP's code won't compile ( user defined type not defined ) and I
don't know what kind of controls he is trying to use.


I didn't try the OP's code but he used TypeOf MSForms.OptionButton and

later
OLEObject.Object, both of which suggest Worksheet controls.

I have Forms toolbar controls on my test worksheet and they have to be
ungrouped in order to read their values.


I slotted the following into the "Resetter" routine I posted earlier

'If shp.Type = msoGroup Then
'code
'ElseIf shp.Type = msoOLEControlObject Then
'code
ElseIf shp.Type = msoFormControl Then
If TypeOf shp.DrawingObject Is Excel.OptionButton Or _
TypeOf shp.DrawingObject Is Excel.CheckBox Then
'or
'If TypeName(shp.DrawingObject) = "OptionButton" Or _
TypeName(shp.DrawingObject) = "CheckBox" Then

Debug.Print shp.Name, shp.DrawingObject.Value
End If
'End if

With grouped Form's controls I can read values (xlOn & xlOff), but I can't
change them.

I think to change these requires storing the original group (& sub group)
structure & names, ungroup, process, regroup riginal structiure, rename

'as
was' including any sub groups. Apart from being relatively slow each

regroup
first gets a new default name and the internal object counter used for

names
increments. There are other properties in GroupObjects that can only be
changed this way, in particular Font (AFAIK).

Regards,
Peter T




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ShemeColor Shape/Group Zurn[_59_] Excel Programming 1 July 24th 06 10:31 AM
Change order in a multi-shape group? Jay Excel Programming 0 April 5th 06 11:43 PM
text in shape group pshen Excel Programming 2 June 8th 05 07:34 PM
Get the name of a group given the reference to a shape within the group Andrew[_16_] Excel Programming 5 January 1st 04 01:08 AM
Reference oleobject within shape group Andrew[_16_] Excel Programming 4 December 24th 03 02:31 AM


All times are GMT +1. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"