Ask Your Question

How to add LibreOffice Basic code to a form button? [closed]

asked 2015-12-12 21:07:40 +0100

TheDatabaseGuy gravatar image

I'm new to coding on LibreOffice Base - can someone please point me in the right direction?

I've create a form containing fields from my query and have added a button to the form.

I want to write and then execute a piece of LibreOffice Basic code when I press the button.

Anything will do at the moment - for example, a message could appear to say "You pressed me!".

I can only see how to assign a pre-defined macro to a button so far (and even then I'm not sure I'm doing it right!)

Help! Please!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-12 18:55:32.301346

2 Answers

Sort by » oldest newest most voted

answered 2015-12-14 16:19:42 +0100

Follow the screenshot's arrows.

If my answer helped you, vote it with ✔ and with ∧ (here on the left)

image description

edit flag offensive delete link more

answered 2015-12-14 15:32:38 +0100

peterwt gravatar image

With your database open from the Menu - Tools > Macros > Organise Macros > LibreOffice Basic. Your database name will be at the bottom of the list on the left hand side. Click on the database name and select New from the right hand buttons. A popup will open with Title "New Module" with default name "Module1" - click OK. The Basic Editor will open with a new blank macro
Sub Main
End Sub

If you enter between these lines as below

Sum Main
MsgBox "You pressed Me!"
End Sub

Attach this Macro to the button.
To Edit or add new Macros use the menu route to the document Macros.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-12-12 21:07:40 +0100

Seen: 1,957 times

Last updated: Dec 14 '15