Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
hjc hjc is offline
external usenet poster
 
Posts: 17
Default find the location of an activeX control

Is there a way to locate an ActiveX control (specifically, a button) in a
spreadsheet, i.e., to find out what column it is in? I can figure it out if
the control has a linked cell that I can put in the same column, but that
doesn't work for a button. Although the 'location' of the left edge of the
button is a property of the button, it doesn't seem to correlate to pixels
(that could be compared against the sum of the widths of the columns to the
left of the control, for example) or anything else, as far as I can tell.

I am trying to create a series of buttons, each of which will carry out the
same action on the column in which it resides. I am using Excel 2003.

Thanks for whatever help anybody can provide!
Hugh John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default find the location of an activeX control

One way...
'--
Sub WhereAreYou()
Dim x As Long
x = ActiveSheet.Shapes("CommandButton1").TopLeftCell.C olumn
MsgBox x
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"hjc"
wrote in message
Is there a way to locate an ActiveX control (specifically, a button) in a
spreadsheet, i.e., to find out what column it is in? I can figure it out if
the control has a linked cell that I can put in the same column, but that
doesn't work for a button. Although the 'location' of the left edge of the
button is a property of the button, it doesn't seem to correlate to pixels
(that could be compared against the sum of the widths of the columns to the
left of the control, for example) or anything else, as far as I can tell.

I am trying to create a series of buttons, each of which will carry out the
same action on the column in which it resides. I am using Excel 2003.

Thanks for whatever help anybody can provide!
Hugh John

  #3   Report Post  
Posted to microsoft.public.excel.programming
hjc hjc is offline
external usenet poster
 
Posts: 17
Default find the location of an activeX control

Thanks, Jim -- that certainly gets me started! Now all I need to know is how
to find out which button was clicked to get me into that routine, so I don't
have to hard-code the name of the button. Is there an easy way to do that?
Thanks!

Hugh John

"Jim Cone" wrote:

One way...
'--
Sub WhereAreYou()
Dim x As Long
x = ActiveSheet.Shapes("CommandButton1").TopLeftCell.C olumn
MsgBox x
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"hjc"
wrote in message
Is there a way to locate an ActiveX control (specifically, a button) in a
spreadsheet, i.e., to find out what column it is in? I can figure it out if
the control has a linked cell that I can put in the same column, but that
doesn't work for a button. Although the 'location' of the left edge of the
button is a property of the button, it doesn't seem to correlate to pixels
(that could be compared against the sum of the widths of the columns to the
left of the control, for example) or anything else, as far as I can tell.

I am trying to create a series of buttons, each of which will carry out the
same action on the column in which it resides. I am using Excel 2003.

Thanks for whatever help anybody can provide!
Hugh John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default find the location of an activeX control


Private Sub CommandButton1_Click()
Call WhereAreYou(Me.CommandButton1.Name)
End Sub


Sub WhereAreYou(ByRef sButt As String)
Dim x As Long
x = Me.Shapes(sButt).TopLeftCell.Column
MsgBox sButt & " is in column " & x & " "
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"hjc"
wrote in message
Thanks, Jim -- that certainly gets me started! Now all I need to know is how
to find out which button was clicked to get me into that routine, so I don't
have to hard-code the name of the button. Is there an easy way to do that?
Thanks!
Hugh John




"Jim Cone" wrote:
One way...
'--
Sub WhereAreYou()
Dim x As Long
x = ActiveSheet.Shapes("CommandButton1").TopLeftCell.C olumn
MsgBox x
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





"hjc"
wrote in message
Is there a way to locate an ActiveX control (specifically, a button) in a
spreadsheet, i.e., to find out what column it is in? I can figure it out if
the control has a linked cell that I can put in the same column, but that
doesn't work for a button. Although the 'location' of the left edge of the
button is a property of the button, it doesn't seem to correlate to pixels
(that could be compared against the sum of the widths of the columns to the
left of the control, for example) or anything else, as far as I can tell.

I am trying to create a series of buttons, each of which will carry out the
same action on the column in which it resides. I am using Excel 2003.
Thanks for whatever help anybody can provide!
Hugh John

  #5   Report Post  
Posted to microsoft.public.excel.programming
hjc hjc is offline
external usenet poster
 
Posts: 17
Default find the location of an activeX control


Thanks, Jim -- that's got it! (Although, I had to use 'ActiveSheet' instead
of 'Me' inside Sub WhereAreYou...as you did in your first post.)

Thanks again!
hjc


"Jim Cone" wrote:


Private Sub CommandButton1_Click()
Call WhereAreYou(Me.CommandButton1.Name)
End Sub


Sub WhereAreYou(ByRef sButt As String)
Dim x As Long
x = Me.Shapes(sButt).TopLeftCell.Column
MsgBox sButt & " is in column " & x & " "
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"hjc"
wrote in message
Thanks, Jim -- that certainly gets me started! Now all I need to know is how
to find out which button was clicked to get me into that routine, so I don't
have to hard-code the name of the button. Is there an easy way to do that?
Thanks!
Hugh John




"Jim Cone" wrote:
One way...
'--
Sub WhereAreYou()
Dim x As Long
x = ActiveSheet.Shapes("CommandButton1").TopLeftCell.C olumn
MsgBox x
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)





"hjc"
wrote in message
Is there a way to locate an ActiveX control (specifically, a button) in a
spreadsheet, i.e., to find out what column it is in? I can figure it out if
the control has a linked cell that I can put in the same column, but that
doesn't work for a button. Although the 'location' of the left edge of the
button is a property of the button, it doesn't seem to correlate to pixels
(that could be compared against the sum of the widths of the columns to the
left of the control, for example) or anything else, as far as I can tell.

I am trying to create a series of buttons, each of which will carry out the
same action on the column in which it resides. I am using Excel 2003.
Thanks for whatever help anybody can provide!
Hugh John


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
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
publish activeX combobox and other activeX control irene c Excel Programming 0 March 19th 07 07:19 AM
Help with using an activex control CrazyPhilll Excel Programming 7 April 24th 06 09:28 AM
How to control "Date Time Picker ActiveX Control" Jafery Excel Programming 1 July 21st 05 02:38 PM
ActiveX control jacob Excel Programming 1 November 22nd 03 06:03 PM


All times are GMT +1. The time now is 05:35 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"