How can one search & replace direct formatting with styles?

I understand how to use Find/Replace to grab things based on text and even specific formatting conditions, as well, but not how to find specific formatting and apply an existing style. I have a number of documents that I’d like to repair the formatting in by switching them to styles.

They are consistently formatted. If I could search for a specific combination of font, text color, and size, and apply a selected style, I’d be done swiftly.

A workaround in Word would be a simple little macro in VB to apply the formatting per, but I can’t get custom macros working worth a hang in LO, either, so I’m kinda stuck with doing this manually or fiddling around in the XML, which isn’t going to hot… or going back to the dark side, I suppose.

Options? Thoughts?

Please, what is your LibreOffice version?

Version 4.0.1.2
Why would that matter? Does 4.0.3 fix it or something?

@dajare: That does sound like it does what I need. Thanks. I wonder why that has yet to be folded into the program.

I gave up on OO/LO macros quite a while back. They have cost me far more time than they ever saved; It’s simply not a feature until I can trust it to consistently work. I’ll probably tinker with it a whit, but not seriously.

Oh, and I can’t vote your answer up, BTW

All point releases (i.e., v4.0.1.2 > v4.0.3.3) are mainly bug fixes. You can check the details under the individual release details. I am not saying this particular issue has been addressed as I haven’t looked.

@YouThere - Re: LO macros: it took a bit of working out for me, too. I posted one use for them here: http://j.mp/Zk4mF3 It might help, especially if (as it sounds like) you’re already familiary with macros from MS Word.

I think you need the Alternative Find & Replace extension (“AltSearch”, below). Recently I was pointed to it for a different task, and it’s a very powerful tool. You will need to save it (from link above) locally, then Tools > Extension Manager… > Add > [browse to saved file, click, etc.] to install.

Once you’ve got it (for me, needed a LO restart; toolbar icon could be prettier! :wink: ) then … how to use it?! There is a help file (linked on the download page), and you can search AskLibo for other answers that explain it. (I had a very helpful reply about it recently which provides one good example.)

I just tried something akin to your question (I think!):

  • Fire up AltSearch.
  • In “Search for:” , choose Properties dropdown > Same format of characters (based on cursor) (= last option) > then FInd All.
  • Give it some time! (Or maybe it’s just that I have an antique laptop!)
  • Once it announces the number of hits found, click in “Replace:” dropdown, choose “Paragraph style”. The list of available styles will pop up.
  • Choose the one you want to apply (double click), and the line will populate.
  • Then > Replace all.
  • Give it some time! :wink: (or maybe it’s my antique, etc.). That should do it.

I tried it with “Hanging indent” on a 15 page (single space) document. Worked a treat.

That might not be the precise set of steps for your use case, but it’s one approach that worked for me (on Linux Mint Xfce + LO 4.0.3). More expert users will hopefully be along shortly! Hope this helps in the meanwhile.

P.s. On macro recording, have you enabled it?

Installation succeeds without errors on my swedish LibreOffice but I can’t find it anywhere in my menus. I’ve read that it should lie under the “Edit” menu but there is no extra “Ext S/R” there. Isn’t this extension supposed to work on the swedish version?!

@Nordlöw - it appears as an icon in your toolbar ← look for the “green binoculars”.

I don’t see any such icon in my LibreOffice. Which toolbar should it lie in?

@Nordlöw - make sure that View > Toolbars > Alternative searching has a “check”.

Sorry, but no Alternative searching entry is shown under View > Toolbars.

@Nordlöw - then it sounds like it has not installed properly. Your i18n or l10n version shouldn’t matter at all. What is your LibO version and platform?

I’m using Ubuntu’s 13.10’s standard Version: 4.1.3.2 Build ID: 410m0(Build:2). Extension manager tells me “Alternative searching 1.4” is installed.

@Nordlöw - I use it regularly in the same setting. Beyond my competence now! The only thng I can think of is resetting the user profile (follow the “Resolving corruption” instructions) and see if that helps. It’s my last idea!

Hi, I can’t fin d the extention anymore ?!
has it become obsolete ?

@jbonlinea - No, it’s not obsolete: it’s still available on the LibreOffice extensions website, which has been restructured since this answer was written. I’ll update the URL in the answer itself, too.

Unfortunately neither Find and Replace nor extended search seem capable of applying both a style and a formatting criterion at once: e.g. there is no way to find italic characters only in Level 3 headings. Until this can be done the program is going to lag seriously behind Word.

I think “lag seriously” is hyperbole since this is functionality that probably applies to less than a fraction of a percent of the user base. Would it be good to have? Sure. The related enhancement is fdo#64970.