Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - Button for macros possible?
Button for macros possible?
 
   NeoOffice Forum Index -> NeoOffice Releases
View previous topic :: View next topic  
Author Message
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Sat Jul 07, 2007 3:17 am    Post subject: Button for macros possible?

Hello,

Is it possible to add a button in Calc that does a specific macro?

I want a button that deletes the information from some cells.

I know this is possible in Microsoft Excel.

Thanks.
Back to top
jgd
Agent Smith


Joined: Feb 27, 2005
Posts: 1531
Location: France

PostPosted: Sat Jul 07, 2007 4:57 am    Post subject:

Yes it's possible.

Go to the View > Toolbars menu and choose Form Controls.

Click on the little triangle on the right top of the toolbar that appears to activate the design mode. Click on the Push button icon. The pointer changes into a cross.

Draw the button as you wish. Control-click it, choose Control in the context menu. Click on the Events tab. Click on the event, for example Mouse button pressed, and click on the Macro button.

Choose your macro. click OK. Quit the design mode by clicking on the little triangle in the top right of the toolbar.

Hope that helps

Jacqueline
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Sat Jul 07, 2007 11:15 am    Post subject:

Great! Thanks alot!
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Sat Jul 07, 2007 12:38 pm    Post subject:

We should add Jacqueline's tip to the Using Macros page (we have assigning shortcuts there, but not buttons).

Edit: Er, I was thinking of toolbar buttons. Well, we still need that, but I pasted Jacqueline's answer in to a section about adding buttons in spreadsheets, since that's what this thread is about Embarassed

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
jgd
Agent Smith


Joined: Feb 27, 2005
Posts: 1531
Location: France

PostPosted: Sun Jul 08, 2007 7:27 am    Post subject:

The same method works in Writer as well. I improved a bit the English page (PPT) and added a section in the Fr one.

Jacqueline
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Mon Jul 09, 2007 1:05 am    Post subject:

It works, but I'm not able to get the macro to work if i mark more then one line to delete. Any ideas?
Back to top
jgd
Agent Smith


Joined: Feb 27, 2005
Posts: 1531
Location: France

PostPosted: Mon Jul 09, 2007 6:26 am    Post subject:

Hmm… It works for me.

Record your macro as follows:
Select a line, delete it. Save the macro.

Add a button as above.

If you want to delete several lines, select them with Shift-Click or Command-Click then press the button.

Jacqueline
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Mon Jul 09, 2007 10:12 am    Post subject:

I do the command-select to select multiple lines. And then press backspace to delete. Then I stop the recording of macro. When I execute the macro it only deletes the first line I selected.

Seems like a bug.
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Mon Jul 09, 2007 10:12 am    Post subject:

I do the command-select to select multiple lines. And then press backspace to delete. Then I stop the recording of macro. When I execute the macro it only deletes the first line I selected.

Seems like a bug.

The workaround I used was to select one line and then press delete. Then another and so on. But that way is kinda stupid. Razz
Back to top
jgd
Agent Smith


Joined: Feb 27, 2005
Posts: 1531
Location: France

PostPosted: Mon Jul 09, 2007 10:35 am    Post subject:

When I recorded the macro, I selected only one line. Then I deleted it by pressing backspace or by going in the Edit > Delete Contents… menu. Stop recording.

To delete several lines with the macro, I select them and press the button. It works.

Did you try to select the lines you want to delete and to go to the
Tools > Macros > Run Macros… menu, then to choose your macro and click on Run? What does occur?

Jacqueline
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Mon Jul 09, 2007 3:21 pm    Post subject:

Thats what I did.. it only deletes the first one I selected.
Back to top
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Tue Jul 10, 2007 12:22 am    Post subject:

I can see what your problem is, as I've come across this one myself. The OOo macro recorder doesn't record the 'select' operation.

If you start recording a macro, then select 3 rows and then choose Delete Rows and then save the macro, all the macro saves is Delete Rows. So after that, if you have no rows selected it'll delete the one the cursor is in, or if you have one or more rows selected, it'll delete all the selected rows.

You can manually add select functions to your macro after recording it: for example:
Code:
dispatcher.executeDispatch(document, ".uno:SelectColumn", "", 0, Array())

selects the column the cursor is in, and likewise:
Code:
dispatcher.executeDispatch(document, ".uno:SelectRow", "", 0, Array())

for the current row. Anything more sophisticated than that is way fiddly and involves proper BASIC code, of which I know nothing...

- padmavyuha

*edit* each of these code snippets is supposed to be on one line, dammit.
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Tue Jul 10, 2007 5:47 am    Post subject:

A bigger problem is that when I quit NeoOffice and reopen the Calc, all macros assigned to buttons are gone. The macros still exist but are not assigned to the buttons. Howcome?
Back to top
jgd
Agent Smith


Joined: Feb 27, 2005
Posts: 1531
Location: France

PostPosted: Tue Jul 10, 2007 8:31 am    Post subject:

Maybe you are having problems with your Preferences folder.
Try to move or rename the
/Users/your_name/Library/Preferences/NeoOffice-2.1 folder and relaunch NeoOffice.
Record the macro again and see if the problem has disappeared or not.
See this page in the wiki to know how to salvage your settings from the Preferences folder.

Jacqueline
Back to top
gompen
Red Pill


Joined: Jul 07, 2007
Posts: 9

PostPosted: Wed Jul 11, 2007 2:46 am    Post subject:

I tried to rename the folder but same thing happened.

I found out that it only happens if I save the sheet as .xls.. It works fine if I save as .ods.
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> NeoOffice Releases All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.