Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Get Active Object or Textbox Name to pass to sub

I have multiple text box - in the mouse down event for each - I want to pass
the name of the textboax to another module something like this

public controlname as control

sub mousedown()
controlname = activesheet.control.name

What is the correct code?

Also the mouse down event seems to happen twice upon one right click -
anyway to stop this - thanks so much for your help!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Get Active Object or Textbox Name to pass to sub

Your mousedown event should look like this

Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)

End Sub

The name is typically "TextBox1". In some (untypical) scenarios the shape
name can be different to the OLEObject name, if you prefer that use
TextBox1.Name

Yes the mousedown event does run twice (I've discussed this before in this
ng). Are you sure GotFocus isn't a more appropriate event, otherwise
MouseUp. If you really need mousedown try something like this -

Static nEvnt As Long
If Button = 2 Then
nEvnt = nEvnt + 1
If nEvnt < 2 Then
Exit Sub
End If
End If
nEvnt = 0


Regards,
Peter T


"Kenny" wrote in message
...
I have multiple text box - in the mouse down event for each - I want to
pass
the name of the textboax to another module something like this

public controlname as control

sub mousedown()
controlname = activesheet.control.name

What is the correct code?

Also the mouse down event seems to happen twice upon one right click -
anyway to stop this - thanks so much for your help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Get Active Object or Textbox Name to pass to sub

Peter thanks so much for your help. I wrote this mouse down (right click)
event that will fire another module and carry the objects name in a variable
with it. Im going to copy the same code to each of the mouse down events for
all textbox's on the sheet. The problem is I have to change "set popobject =
TextBox1" to the objects name in every mouse down event. Is there a way to
give the variable the object's name of which ever objects mousedown event I
am in. Such as "set popobject = Selected.Objects.Name" or something to that
effect.


"Peter T" wrote:

Your mousedown event should look like this

Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, ByVal Y As Single)

End Sub

The name is typically "TextBox1". In some (untypical) scenarios the shape
name can be different to the OLEObject name, if you prefer that use
TextBox1.Name

Yes the mousedown event does run twice (I've discussed this before in this
ng). Are you sure GotFocus isn't a more appropriate event, otherwise
MouseUp. If you really need mousedown try something like this -

Static nEvnt As Long
If Button = 2 Then
nEvnt = nEvnt + 1
If nEvnt < 2 Then
Exit Sub
End If
End If
nEvnt = 0


Regards,
Peter T


"Kenny" wrote in message
...
I have multiple text box - in the mouse down event for each - I want to
pass
the name of the textboax to another module something like this

public controlname as control

sub mousedown()
controlname = activesheet.control.name

What is the correct code?

Also the mouse down event seems to happen twice upon one right click -
anyway to stop this - thanks so much for your help!




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
pass to textbox on a form and to excel worksheet cvw New Users to Excel 0 March 16th 10 07:35 PM
OnTime: Pass Object Arguments Greg Lovern Excel Programming 6 October 12th 07 12:50 AM
Pass a range object as a parameter clara Excel Programming 5 April 27th 07 05:34 AM
Pass object by value not working... Lyndon[_2_] Excel Programming 6 January 22nd 07 11:34 PM
How to pass active workbook to external DLL? MarkDev Excel Programming 4 August 13th 06 02:19 PM


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