Language Selection

English French German Italian Portuguese Spanish

OOoBasic crash course: Working with files

Filed under
HowTos

OpenOffice.org's OOoBasic gives users tools to programmatically access and manipulate files. To see how that works, we'll create a simple macro that allows you to save text snippets from the current document in a plain text file. This macro can be used to store text fragments from multiple documents in one text file, or to save deleted passages in an external file in case you need them later.

To build this macro, you can reuse the component that grabs the selected text fragment in the current document. If you've followed the previous installments of the OOoBasic crash course series on creating a lookup macro and working with words, the following code will look familiar:

Sub WriteFile()
Dim oDoc As Object, oText As Object
Dim oCursor As Object
Dim sFileName As String
oDoc=ThisComponent
oText=oDoc.Text
oCursor=oDoc.CurrentController.getViewCursor
If oCursor.String ="" then MsgBox "Please select a word to look up" : End

Notice the sFileName variable, defined as string. This variable points to the file for use in the macro. To specify the file you want, use the following code:

Full Story.

More in Tux Machines

Linux and Linux Foundation

Security Leftovers

Qt 5.10 and digiKam

  • Qt 5.10 Platform Support Changes Being Discussed
    Qt developers have begun a fresh round of discussions over the supported platforms / operating systems of Qt 5.10 that will be released in the later part of this calendar years. Among the officially supported Linux distribution changes would be moving to RHEL 7.3, openSUSE Leap 42.2, Ubuntu 17.04 (still keeping around 16.04 LTS too), moving the Windows MinGW to MinGW 6.3, and more.
  • digiKam – A Professional Photo Editing and Management Software
    digiKam is an advanced cross-platform digital photo management app inspired by photographers’ needs to view, tweak, enhance, organize, and share photographs across Linux systems. It possesses all the tools and feature set necessary to process, manage, organize, and transfer photographs, videos, and RAW files – while consistently receiving optimization upgrades to its feature set and workflow.

GNOME/Unity in Ubuntu