| View previous topic :: View next topic |
| Author |
Message |
matteo_callimaco General User

Joined: 19 Nov 2006 Posts: 23
|
Posted: Sat Dec 30, 2006 2:11 am Post subject: How to get the active command? |
|
|
Hi all!
I have a problem whit getting the name of a command which is in a spreadsheet.
The command is a combobox and this command has a macro asssociated whit its event "textChanged". The macro which is callled by the command needs the name of the command itself and, since there are several comboboxes which refere to the same macro, I can catch the name manually.
When I change the text in the combobox the focus is on it because I've the cursor in it and so I think that there will be something that tells about the active command....
I've tried
| Code: |
oDoc = ThisComponent
oSheet = oDoc.sheets.getByName("Table1")
oDP = oSheet.Drawpage
oForm = oDP.Forms.getByName("Standard")
Command = oForm.ActiveCommand
|
but this doesn't work.
Any suggestion?
Thanks to all will help! |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Sat Dec 30, 2006 2:43 am Post subject: |
|
|
What you call command is probably the control. A ComboBox is a control. A button is also a control.
I understand you need the name of the control which triggered the event you are handling.
Easy: | Code: | Sub onTextChanged(evt as object)
dim myControl as object
myControl = evt.Source
if myControl.Name = "xxxx" then
' etc...
end if
End Sub
|
|
|
| Back to top |
|
 |
matteo_callimaco General User

Joined: 19 Nov 2006 Posts: 23
|
Posted: Sat Dec 30, 2006 6:33 am Post subject: |
|
|
Thank you!
Only one last question...I have several CONTROLS which have the same macro associated with the same event ("textChanged"). This will create problems in the detection of the trigger control?
The macro associated to controls doesn't know which control has been activated and so I can't use the search by name as you do with if MyControl.name = "xxxx"
And finally, what about evt As Object?
I can't insert argument in my macro...so I need to reply it in the code of the sub. What is that object? |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
|
| Back to top |
|
 |
matteo_callimaco General User

Joined: 19 Nov 2006 Posts: 23
|
Posted: Sat Dec 30, 2006 7:49 am Post subject: |
|
|
| Thank you ms777! You're always the best! |
|
| Back to top |
|
 |
|