Ask Your Question
0

find field, replace by plain text, keep formating

asked 2021-03-13 08:43:34 +0200

xerostomus gravatar image

I have a book just before sending to my publisher. I need to replace all fields by plain text but keep formating at the same time. Have you any idea how to do it by macro or any other way than by hand? I have hundreds of fields in my document.

Honestly, I have no idea. There even isn't any tool how to find a field.

edit retag flag offensive close merge delete

Comments

If you observed strict styling strategy, your fields have received a character style. This character style will not be removed during the transformation field→text. If you didn't, you'll have to restore the formatting.

ajlittoz gravatar imageajlittoz ( 2021-03-13 09:33:38 +0200 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2021-03-13 09:08:10 +0200

JohnSUN gravatar image

updated 2021-03-13 09:08:42 +0200

Believe it or not, this problem was solved many years ago, the solution is described in the Wiki:Converting fields into text, but unfortunately the link to the forum does not work (it does not work for me, perhaps you can find that topic)

The code that does this trick is very simple:

Sub FieldsToText 'Writer Only!'
Dim oDoc,oFields,oEnum,ThisField
   oDoc = ThisComponent
   oFields = oDoc.getTextFields
   oEnum = oFields.createEnumeration
   While oEnum.HasMoreElements
       ThisField = oEnum.nextElement
       ThisField.Anchor.String = ThisField.Anchor.String
   Wend
End Sub

(This was written 6 years ago, I haven't tested it, but it should still work)

edit flag offensive delete link more

Comments

FTR: the archived version of the forum topic mentioned in the Wiki is here.

Mike Kaganski gravatar imageMike Kaganski ( 2021-03-13 10:00:11 +0200 )edit

So, JohnV write it Sat Feb 12, 2011? More then 10 years ago... Thank you!

JohnSUN gravatar imageJohnSUN ( 2021-03-13 10:08:31 +0200 )edit

Believe me or not - I love when smart people are generous! Thank you all! :-) PS. It works almost perfectly - only table of contents and links to pictures remained intact. So no problem, I can cope...

xerostomus gravatar imagexerostomus ( 2021-03-14 09:47:31 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-03-13 08:43:34 +0200

Seen: 27 times

Last updated: Mar 13