Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Reference oleobject within shape group

I have a group of shapes which includes an MSForms.SpinButton. I can
reference this using the following:

Dim sh As Shape
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)
Debug.Print sh.Name

However, I want to set the reference to the OLE object not just the
shape (so that I can use WithEvents to trap the change event). Is
there a simple way to do this? Something like:

Dim sh as MSForms.Spinbutton (OR OLEObject)
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)

So far the best I can do is to ungroup the shapes, set the reference
and then re-group them. It works but it seems like there should be a
neater way.

Thanks a lot,
Andrew
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Reference oleobject within shape group

Hi Andrew,

I have a group of shapes which includes an MSForms.SpinButton. I can
reference this using the following:

Dim sh As Shape
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)
Debug.Print sh.Name

However, I want to set the reference to the OLE object not just the
shape (so that I can use WithEvents to trap the change event). Is
there a simple way to do this? Something like:

Dim sh as MSForms.Spinbutton (OR OLEObject)
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)


How about:

Dim sh as MSForms.Spinbutton
Set sh = Sheets("Overview").Shapes("Group 447") _
.GroupItems(2).OLEObject.Object

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Reference oleobject within shape group

Stephen,

Thanks for the help. When I run your suggestion I get an error though
("Obj doesn't support this method or property"). I wonder if I'm
stuck here because GroupItems seems to only return a shape object.
Let me know if you've got any other ideas though.

Thanks,
Andrew


Stephen Bullen wrote in message ...
Hi Andrew,

I have a group of shapes which includes an MSForms.SpinButton. I can
reference this using the following:

Dim sh As Shape
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)
Debug.Print sh.Name

However, I want to set the reference to the OLE object not just the
shape (so that I can use WithEvents to trap the change event). Is
there a simple way to do this? Something like:

Dim sh as MSForms.Spinbutton (OR OLEObject)
Set sh = Sheets("Overview").Shapes("Group 447").GroupItems(2)


How about:

Dim sh as MSForms.Spinbutton
Set sh = Sheets("Overview").Shapes("Group 447") _
.GroupItems(2).OLEObject.Object

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Reference oleobject within shape group

Hi Andrew,

Thanks for the help. When I run your suggestion I get an error though
("Obj doesn't support this method or property"). I wonder if I'm
stuck here because GroupItems seems to only return a shape object.
Let me know if you've got any other ideas though.


Sorry, I mistyped:

Dim oShp As Shape
Dim oSpn As msforms.SpinButton

Set oShp = ActiveSheet.Shapes(1)
Set oSpn = oShp.GroupItems(2).OLEFormat.Object.Object

The easiest way to work out the reference path is to put a breakpoint
after setting the shape object reference, then display the Locals window
in the IDE and expand out the oShp variable - examining each GroupItem,
OLEFormat and Object property until you find the one of Type
'Object/SpinButton'.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Reference oleobject within shape group

Stephen,

That's great. I've never found a use for the locals window before so
that was really interesting.

Cheers,
Andrew


Stephen Bullen wrote in message ...
Hi Andrew,

Thanks for the help. When I run your suggestion I get an error though
("Obj doesn't support this method or property"). I wonder if I'm
stuck here because GroupItems seems to only return a shape object.
Let me know if you've got any other ideas though.


Sorry, I mistyped:

Dim oShp As Shape
Dim oSpn As msforms.SpinButton

Set oShp = ActiveSheet.Shapes(1)
Set oSpn = oShp.GroupItems(2).OLEFormat.Object.Object

The easiest way to work out the reference path is to put a breakpoint
after setting the shape object reference, then display the Locals window
in the IDE and expand out the oShp variable - examining each GroupItem,
OLEFormat and Object property until you find the one of Type
'Object/SpinButton'.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

Reply
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
my curser changed from arrow shape to a cross shape???? bj New Users to Excel 1 February 5th 07 02:47 PM
Deleting a shape and the cell contents the shape is in. Tom Ogilvy Excel Programming 0 October 9th 03 03:43 AM
Need to cast OleObject to CombBbox Liline Excel Programming 1 August 29th 03 03:32 PM
OLEobject on the sheet Ryan[_6_] Excel Programming 1 August 3rd 03 03:15 PM
Using a variable to represent a Checkbox Name(OLEObject) Mike Cooper Excel Programming 1 July 16th 03 09:40 PM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"