OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to get the active command?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
matteo_callimaco
General User
General User


Joined: 19 Nov 2006
Posts: 23

PostPosted: Sat Dec 30, 2006 2:11 am    Post subject: How to get the active command? Reply with quote

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
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Sat Dec 30, 2006 2:43 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
matteo_callimaco
General User
General User


Joined: 19 Nov 2006
Posts: 23

PostPosted: Sat Dec 30, 2006 6:33 am    Post subject: Reply with quote

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
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sat Dec 30, 2006 7:18 am    Post subject: Reply with quote

TAG is the keyword to search for ... see http://www.oooforum.org/forum/viewtopic.phtml?t=35571&highlight=tag and B Marcelly's reference therein
Back to top
View user's profile Send private message
matteo_callimaco
General User
General User


Joined: 19 Nov 2006
Posts: 23

PostPosted: Sat Dec 30, 2006 7:49 am    Post subject: Reply with quote

Thank you ms777! You're always the best!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group