[Solved] Find & Replace in multiple documents & master docs

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
greyham
Posts: 25
Joined: Sun Mar 30, 2008 9:05 am

[Solved] Find & Replace in multiple documents & master docs

Post by greyham »

I'm working on a 400 page document arranged as a master document with about 30 sub-documents; one for each chapter. I want to do about 30 global find and replaces over all chapters. Opening the master document and using Find and Replace doesn't actually replace anything, because you can't edit subdocuments directly in the master document. Is there any simple or automated way to do this, without having to open every chapter and perform each find and replace seperately? 30 x 30 = ~900 find and replaces, which is going to take quite a while.

Thanks,
Graham
Last edited by Hagar Delest on Mon Jun 09, 2008 10:20 pm, edited 2 times in total.
Reason: tagged the thread as Solved.
Safway
Volunteer
Posts: 347
Joined: Thu Apr 24, 2008 4:35 pm

Re: Find and Replace in multiple documents & master documents

Post by Safway »

After reading http://www.oooforum.org/forum/viewtopic.phtml?t=14928 I don't think you can within the OOo graphical interface the way you are thinking. Another way of doing it would be to open all your sub-documents at once as editable documents. Begin searching for the global text in one sub-document and keep the Find & Replace window open when you go to the next sub-document and do the same with the next sub-document and the next sub-document. The trick is to realize that the Find & Replace window remembers the search/replace texts between sub-documents edits (at least with OOo version 2.4).

Are you opposed to using another tool to do so? If not, what Operating System are you using? The sed program is one of the many tools in the UNIX family that will solve what you need.
If someone posts a fix for your question, then please post a quick thank you and then go to your first post, use the edit button to add [Solved] as the first word of the title so other people can rely on the fix as well.
LibreOffice 3.3.3 on Fedora
User avatar
foxcole
Volunteer
Posts: 1507
Joined: Mon Oct 08, 2007 1:31 am
Location: Minneapolis, Minnesota

Re: Find and Replace in multiple documents & master documents

Post by foxcole »

greyham wrote:Opening the master document and using Find and Replace doesn't actually replace anything, because you can't edit subdocuments directly in the master document.
Actually, you can edit that content by unprotecting the sections. However, even if you do that, you're only editing a copy of each subdocument as it stood when you opened the master, which follows the "links" you placed in the master's Navigator. Those aren't in fact links, they're just pointers to show the master where to find the file to be copied in.

If you don't want to use an external batch tool, one alternative might be to record a macro while you perform all thirty changes in a document, then assign the macro to a toolbar button or key combination. Make sure you don't store the macro locally in the document but in your macro library. If you need more specific instructions on how to do that, please ask. This won't be quite as easy as a batch job because you'll still need to open twenty-nine other documents and run the macro, but it is better than doing the changes one at a time, I think you'll agree.
Cheers!
---Fox

OOo 3.2.0 Portable, Windows 7 Home Premium 64-bit
greyham
Posts: 25
Joined: Sun Mar 30, 2008 9:05 am

[SOLVED]Re: Find and Replace in multiple documents & master

Post by greyham »

foxcole wrote:record a macro while you perform all thirty changes in a document, then assign the macro to a toolbar button or key combination. Make sure you don't store the macro locally in the document but in your macro library.
Excellent suggestion; thank you for this tip. What I have ended up doing is recording a macro to make a single change, and then editing the macro code manually to call the Find/Replace function multiple times with the different Search and Replace strings. The toolbar tip makes big difference too; it's easy to open 30 documents in one hit and then push my new toolbar button once for each. I am new to this level of stuff, so I was happy to find that it was doable once I had your tip.

Thanks!
Graham
Post Reply