[Solved] Push button macro

Creating a macro - Writing a Script - Using the API

[Solved] Push button macro

Postby Andyp » Thu Feb 07, 2008 3:28 pm

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
Andyp
 
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Postby TerryE » Thu Feb 07, 2008 4:09 pm

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.
TerryE
Volunteer
 
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Postby Andyp » Thu Feb 07, 2008 4:19 pm

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
Andyp
 
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Postby TerryE » Thu Feb 07, 2008 5:05 pm

Andy, I just did my test with a shape action pointing to
Code: Select all   Expand viewCollapse view
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.
TerryE
Volunteer
 
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Postby Andyp » Thu Feb 07, 2008 6:01 pm

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
Andyp
 
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Postby TerryE » Thu Feb 07, 2008 10:19 pm

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   Expand viewCollapse view
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.
TerryE
Volunteer
 
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK

Re: Push button macro

Postby Andyp » Fri Feb 08, 2008 11:58 am

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

Andy
Andyp
 
Posts: 9
Joined: Thu Feb 07, 2008 3:24 pm

Re: Push button macro

Postby TerryE » Fri Feb 08, 2008 3:17 pm

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.
TerryE
Volunteer
 
Posts: 1402
Joined: Sat Oct 06, 2007 10:13 pm
Location: UK


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests