# Manipulate Writer selection via macro [closed]

I'm not too bad with VBA, but I simply have not been able to get to first base with OO.o/LO's macro basic code. The verbosity and the editor present major challenges to me. Maybe if I can get one macro going I'll begin to understand.

I'm trying to take a selection and add set text before and after it. I do this to add mark-up for forum posts, so the text I add consists of tags.

When I do this in Word, I have VBA extend the range of the selection to the paragraph beginning and end, so that I don't have to be careful with my selection, I just have to be in the paragraphs I want to include. But that isn't necessary.

I'm in LO 4 on Win7.

Thanks.

edit retag reopen merge delete

### Closed for the following reason question is not relevant or outdated by Alex Kemp close date 2015-10-25 05:51:03.899169

Hit the brick wall again with ooo/lo macros, and no meaningful help available. Apparently one has to be an accomplished coder to make any progress. This was a major reason I abandoned OOo years ago, and I see that little has changed. This makes the open software useful for the low-level user only.

( 2013-01-03 19:29:51 +0200 )edit

Sort by » oldest newest most voted
A LibreOffice Basic macro to wrap selected text in Web markup.
by Hank Davis, Seattle WA

While serving as the Technical Editor of Seattle's nonprofit Victory Review
(www.victorymusic.org), I ported a number of my MS Word VBA Web authoring macros
over to OpenOffice, and from there to LibreOffice. Here is one, with procedures
for using it and embedded remarks. Critiques and improvements from the
open source community are welcome.

For example, you might want to define your own base class for paragraph elements,
rather than use Microsoft's "MsoNormal" class. And most large sites rely on global
CSS stylesheets, rather than use inline styles. So rather than take this listing as
gospel, think of it as a little "demonstration of concept" to build upon and modify
as you like.

I. Enable the LibreOffice Advanced and Macro Security Options.
A. On the Tools menu, select Options.
B. In the Options dialog, under the LibreOffice node, choose Advanced
and select the checkboxes for these options:
Enable experimental features
Enable macro recording
C. Choose the LibreOffice Security options, click the Macro Security button,
and set your Security Level to Medium.
D. [Optional -- If you are working on a home computer that is secure]
...\ Application Data \ LibreOffice \ 4 \ user \ template folder
as a Trusted File Location, and store your .bas files
of Basic macros there, along with the templates that use them.

A. Create a LibreOffice Writer document, and save it to your hard drive.
B. From the Tools menu, select Macros > Organize Macros > Libre Office Basic.
C. Expand the Object Catalog in the left pane, select the node for
D. Name your new macro module, and click OK.
E. Click Edit. Your module should be selected in
the Object Catalog pane on the left.
F. In the code pane on the right, paste in the subroutine
and functions that follow.

III. Try out this macro.
A. Type a few dummy lines into your doc, using blank lines
for paragraph breaks. For example:

First paragraph.
Second paragraph.

Third paragraph.
Fourth paragraph.

B. Select the lines that you typed.
C. From the Tools menu, select Macros > Run Macro.
D. In the "Library ...
more