Reference manual for OOo Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Paddy Landau
Posts: 153
Joined: Wed Nov 28, 2007 12:52 pm

Reference manual for OOo Basic

Post by Paddy Landau »

This is probably a dumb question that's been asked elsewhere, and unfortunately I can't find the answer:

I've searched high and low, and can't find a simple reference manual for OOo Basic.

For example:
  • What values TextWrap could take?
  • What command would let me insert a picture into a Writer document?
And so on.

Where is the reference manual for OOo Basic, please?
Ubuntu Hardy 8.04, OpenOffice.org 3.1.1 build 9420
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Reference manual for OOo Basic

Post by Villeroy »

The Basic language is almost completely documented in the online help. What you want is the documentation of the thing you talk to. Basic is one of several languages that can be used to put a spell on the office API. The topmost link in this forum's Macros and API Forum provides a good starting point.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Paddy Landau
Posts: 153
Joined: Wed Nov 28, 2007 12:52 pm

Re: Reference manual for OOo Basic

Post by Paddy Landau »

Hmm...

Thanks for the pointer. I have gone through that (the Basic Programming Guide) already.

Are you saying that, having gone through the tutorial, I should look at the API documentation?

For example, how would I know how to use a selected object? (I know it's as follows, but how would I know if someone hadn't told me?)

Code: Select all

Dim MyItem as Object
MyItem = ThisComponent.CurrentSelection
That's what I'm trying to get at. Where is the documentation that will help me learn this stuff?

For example, I want to change the current selection (which is a picture) to having "Wrap Through" (MyItem.TextWrap = 1) but also "In background" (and I can't find out how to do that).
Ubuntu Hardy 8.04, OpenOffice.org 3.1.1 build 9420
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Reference manual for OOo Basic

Post by Villeroy »

Once you are familiar with the general structure (UNO with it's services and interfaces) you can lookup things quickly from the reference. The debug window in the Basic editor exposes most of the used objects. You may have a look at the macros that ship with OOo. Some of them are introspective.
A local copy of the Software Development Kit includes the whole reference plus developer's guide both in html. The binary tools are needed for compiling programs in C++ or Java.
Writing scripts in Basic, BeanShell, JavaScript or Python and having a local copy of the SDK you certainly want to install the xray tool (47 matches when searching this forum).

Oh, and then there is a firefox plugin https://addons.mozilla.org/de/firefox/addon/4102 comprising the most important(?) sources of information.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Paddy Landau
Posts: 153
Joined: Wed Nov 28, 2007 12:52 pm

Re: Reference manual for OOo Basic

Post by Paddy Landau »

Wow! Thanks, Villeroy.

I'm just wanting to write simple macros for repetitive work in my text documents, so it may be too much. I'll take a look and see what I need and if I can use just the basic bits!

Thanks again.
Ubuntu Hardy 8.04, OpenOffice.org 3.1.1 build 9420
User avatar
Paddy Landau
Posts: 153
Joined: Wed Nov 28, 2007 12:52 pm

Re: Reference manual for OOo Basic

Post by Paddy Landau »

I've installed the add-on. It's rather handy!
Ubuntu Hardy 8.04, OpenOffice.org 3.1.1 build 9420
User avatar
kingfisher
Volunteer
Posts: 2123
Joined: Tue Nov 20, 2007 10:53 am

Re: Reference manual for OOo Basic

Post by kingfisher »

I have some notes of various resources at http://kingfisher.wikidot.com/insert:ooscript
Apache OpenOffice 4.1.9 on Linux
User avatar
Paddy Landau
Posts: 153
Joined: Wed Nov 28, 2007 12:52 pm

Re: Reference manual for OOo Basic

Post by Paddy Landau »

Thanks. I've bookmarked the page and will go through that, too.
Ubuntu Hardy 8.04, OpenOffice.org 3.1.1 build 9420
Craig9173
Posts: 1
Joined: Fri May 13, 2011 12:09 pm

Re: Reference manual for OOo Basic

Post by Craig9173 »

Paddy Landau wrote:Hmm...

Thanks for the pointer. I have gone through that (the Basic Programming Guide) already.

Are you saying that, having gone through the tutorial, I should look at the API documentation?

For example, how would I know how to use a selected object? (I know it's as follows, but how would I know if someone hadn't told me?)

Code: Select all

Dim MyItem as Object
MyItem = ThisComponent.CurrentSelection
That's what I'm trying to get at. Where is the documentation that will help me learn this stuff?

For example, I want to change the current selection (which is a picture) to having "Wrap Through" (MyItem.TextWrap = 1) but also "In background" (and I can't find out how to do that).
I am in the same boat, I understand the basic bits and bobs, but I am trying to understand how to reference a cell. unfortunately I can only describe this with blasphemy, myvariable = worksheets("sheet1").cells(3,4)

I dont really understand what UNO or API are, I do understand what basic is (Fortran 77 is where I cut my programming teeth, but unfortunately that is where I have stayed for 20 years)
OpenOffice 3.3.0 on Windows 7 Toshiba NB305 netbook
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Reference manual for OOo Basic

Post by RoryOF »

API stands for Application Programming Interface and UNO for Universal Network Objects; for people who started on Fortran (F II in my case) and BASIC, they are a major change in concept. Pascal and Modula 2 were straightforward, but then C and its various varieties did not sit well (for me at any rate) with the structured logic of Pascal and Modula. One really misses a printed out reference manual for the API etc for a specific application.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Re: Reference manual for OOo Basic

Post by rudolfo »

Craig, you jumped onto an old thread. In general the Macro Forum has a sticky topmost thread now that reflects a discussion on how to find documentation. Short summary: Wiki documenation on Basic, UNO API documentation, Tutorials, Inspection tools (MRI, Xray)
In your case coming from MS Office and VBA the document VBA - StarBasic Cross Reference might also be helpful.
At the end you should find something like the following for your question:

Code: Select all

oSheet = ThisComponent.getSheets().getByName("Sheet1")
oCell = oSheet.getCellByPosition(3,2)   ' Cell D3
OpenOfffice counts cells in a table starting from index 0 and the first parameter is the column and the second the row.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
franc
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: Reference manual for OOo Basic

Post by franc »

OpenOffice 3.3
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Reference manual for OOo Basic

Post by Villeroy »

It gives a cooking receipt for a tiny problem you may have at this moment. It does not explain anything. Next time you need another receipt.
rudolfo wrote: At the end you should find something like the following for your question:

Code: Select all

oSheet = ThisComponent.getSheets().getByName("Sheet1")
oCell = oSheet.getCellByPosition(3,2)   ' Cell D3
OpenOfffice counts cells in a table starting from index 0 and the first parameter is the column and the second the row.
Or even

Code: Select all

oCell = ThisComponent.Sheets.getCellByPosition(3,2,1)   ' Cell D3 on second sheet
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
franc
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: Reference manual for OOo Basic

Post by franc »

Coming from VBA with IntelliSense and a good integrated help, it is hard and stony to get started with SB.
OpenOffice 3.3
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Reference manual for OOo Basic

Post by Villeroy »

franc wrote:Coming from VBA with IntelliSense and a good integrated help, it is hard and stony to get started with SB.
Coming from VBA, anything else is difficult. Just change your tools and your mind set. Install the MRI extension, explore its capabilities.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
franc
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: Reference manual for OOo Basic

Post by franc »

Yes, it is really different ;)
Having now installed the MRI, Xray, SDK. Reading the doc and exploring the objects...

Thank it.
OpenOffice 3.3
franc
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: Reference manual for OOo Basic

Post by franc »

It becomes...
But slowly :)

One little question: How can I set the cursor to the last position, when I want to create a new text document and fill it with text from a database?
I want to sequentially fill a new text document paragraph by paragraph with content (strings) from a calc-"database", e.g.:

Fill one new paragraph1 with StringA, then StringB, then StringC.
Fill one new paragraph2 with StringD, then StringE, then StringF.
Fill one new paragraph3 with ...
...
Fill paragraphN with String N, then StringN+1, then StringN+2

Sorry when asking this, maybe I should use other subforum?
thank anyway.
OpenOffice 3.3
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Reference manual for OOo Basic

Post by FJCC »

I think I can help with your question, but please start a new topic so that others can find the answer also.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
franc
Posts: 21
Joined: Sat Oct 08, 2011 2:12 pm

Re: Reference manual for OOo Basic

Post by franc »

FJCC wrote:...but please start a new topic...
I did it:

http://user.services.openoffice.org/en/ ... 45&t=47571
OpenOffice 3.3
Post Reply