Working with OpenOffice.org Documents

From Wiki
Jump to navigationJump to search


The OpenOffice.org API has been structured so that as many of its parts as possible can be used universally for different tasks. This includes the interfaces and services for creating, opening, saving, converting, and printing documents and for template administration. Since these function areas are available in all types of documents, they are explained first in this chapter.

The current document

In previous versions of the Basic Programming Guide these instructions were used to obtain the current document :

Dim Doc As Object

Doc = StarDesktop.CurrentComponent

This correct code has a drawback : it does not work if the macro is started from the IDE because it then refers to the IDE, not the document. This code works only if the macro is started from the document itself!

You should instead use Basic object ThisComponent. It returns the document object on which the macro is run. If you start the macro from the IDE, ThisComponent will still find and return your document.

Dim Doc As Object

Doc = ThisComponent ' recommended coding for Basic

fr:FR/Documentation/BASIC Guide/Documents hu:HU/Documentation/BASIC Guide/Documents it:IT/Documentation/BASIC Guide/Documents ja:JA/Documentation/BASIC Guide/Documents zh:ZH/Documentation/BASIC Guide/Documents


Content on this page is licensed under the Public Documentation License (PDL).