Ask Your Question
0

Manipulate Writer selection via macro [closed]

asked 2013-01-02 04:45:51 +0200

paul1149 gravatar image

updated 2015-10-25 05:50:40 +0200

Alex Kemp gravatar image

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 flag offensive 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

Comments

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.

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

1 Answer

Sort by » oldest newest most voted
0

answered 2013-03-02 04:33:44 +0200

Hank D gravatar image
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] 
         On the Trusted Sources tab of Macro Security, add your 
         ...\ 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.

II. Add the macro and functions that follow to your document.
    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  
         your document, and click New.
    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.
    G. Compile and Save, then Close the Basic dialog and return to your doc.

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)
edit flag offensive delete link more

Comments

@paul1149 -- Does this answer work for you?

qubit gravatar imagequbit ( 2013-03-14 01:40:40 +0200 )edit

Question Tools

2 followers

Stats

Asked: 2013-01-02 04:45:51 +0200

Seen: 1,987 times

Last updated: Mar 02 '13