[Solved] Push button macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Andyp
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

[Solved] Push button macro

Post by Andyp »

I have attached a simple macro to a push button which works okay , however , when I press this button the design toolbar come on every time I press it , very frustrating , great product , obvioulsly Im missing something here.
many thanks

Andyp
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Post by TerryE »

Andy, please read the Survival Guide for the forum. This give basic guidance on how to look for answers, and how to frame you questions to help us to help you. So what package are you doing this in? Calc, Writer or what? What is the context. You've got to give us a clue, eh?

If your macro is a Basic macro (e.g. ActionButton1) then your macro properties should be something like:
  • Mouse button pressed vnd.sun.star,script?Standard.Module1.ActionButton?language=basic&location=document(.)
This should throw directly into the macro, and no design toolbars should appear
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
Andyp
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Post by Andyp »

Thanks Terry , sorry am using calc , and your answer does show when mouse button pressed the correct syntax.
However I can get the macro working okay , but when I save and re-load and go to the button it goes into design mode striaght off and no toolbar shows i.e Form controls.
Sorry Im new to this.
Thanks for your help.

Andy
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Post by TerryE »

Andy, I just did my test with a shape action pointing to

Code: Select all

Sub ActionButton
Print "Hello World"
End Sub
A save / close / reopen bring the spreedstheet back in the corect context and pressing the shape gives a message box containing "Hello World".

What does your macro do? What is its context?

The only way I can get it to go into design mode is to right click on the button.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
Andyp
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Post by Andyp »

Thanks Terry, my macro is just a goto to another sheet. I have managed to get this to work okay in a new file.
I think the problem my be with the original file which was converted from Excel , when I look at the code for the macro is states the following first line;
Rem Attribute VBA_ModuleType=VBAModule , where in the new book I tried it states REM ****bASIC **** in first line, this may be where the problem maybe but would not now what the answer is ?

cheers

andyp
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Post by TerryE »

Ah, the light dawns. The Survival Guide is there for a reason. You didn't give a full explanation. When you convert a XLS spreadsheet with a VBA macro, the macro code is REMmed out since the VBA and OOo APIs are different. The subroutine that you need to go to another sheet is

Code: Select all

Sub GotoSheet2
ThisComponent.CurrentController.ActiveSheet = ThisComponent.Sheets.getByName("Sheet2")
End Sub
where you need to change the Sheet2 to whatever.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
Andyp
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Post by Andyp »

Thanks Terry , soory for not giving you full info , it now works fine.
Thanks a lot.

Andy
TerryE
Volunteer
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Post by TerryE »

Andy, we're here to help. Glad to oblige.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
Post Reply