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

today's howtos

Leftovers: Gaming

Leftovers: KDE (Akonadi, KWin)

  • Akonadi for e-mail needs to die
    So, I'm officially giving up on kmail2 (i.e., the Akonadi-based version of kmail) on the last one of my PCs now. I have tried hard and put in a lot of effort to get it working, but it costs me a significant amount of time and effort just to be able to receive and read e-mail - meaning hanging IMAP resources every few minutes, the feared "Multiple merge candidates" bug popping up again and again, and other surprise events. That is plainly not acceptable in the workplace, where I need to rely on e-mail as means of communication. By leaving kmail2 I seem to be following many many other people... Even dedicated KDE enthusiasts that I know have by now migrated to Trojita or Thunderbird.
  • Virtual keyboard support in KWin/Wayland 5.7
    Over the last weeks I worked on improved input device support in KWin/Wayland and support for virtual keyboard. KWin 5.7 will integrate the new QtVirtualKeyboard module which is now available under GPLv3. For us this means that we have access to a high quality QML based keyboard. For Qt it means that the virtual keyboard is exposed to more users and thanks to the open source nature it means that we can upstream fixes.
  • Virtual Keyboard Support For KWin / KDE Wayland 5.7
    The latest KWin/Wayland hacking project by Martin Gräßlin is adding virtual keyboard support to KWin for the upcoming KDE Plasma 5.7 release. This virtual keyboard support is powered by the QtVirtualKeyboard module and provides a high-quality, QML-based keyboard that will work on KWin/Wayland when no hardware keyboard is available. Implementing this virtual keyboard support with Wayland compatibility was actually quite a feat, but has now become a reality thanks to the work by Martin.

Red Hat News