Difference between revisions of "Documentation/OOoAuthors User Manual/Writer Guide/Tricks for working with fields"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
(Converting fields into text)
Line 19: Line 19:
 
== Converting fields into text ==
 
== Converting fields into text ==
 
Writer does not provide any easy way to convert field contents into text. To do this, you need to copy the field contents and paste them back as unformatted text. This is not a very good solution if you have hundreds of fields that you want to change, but you could use a macro to automate the process.
 
Writer does not provide any easy way to convert field contents into text. To do this, you need to copy the field contents and paste them back as unformatted text. This is not a very good solution if you have hundreds of fields that you want to change, but you could use a macro to automate the process.
 +
 +
A suggested macro is provided as below. (Credits: JohnV from Openoffice Forums)
 +
 +
Sub FieldsToText
 +
oDoc = ThisComponent
 +
oFields = oDoc.getTextFields
 +
oEnum = oFields.createEnumeration
 +
While oEnum.hasMoreElements
 +
oNext = oEnum.nextElement
 +
oNext.Anchor.String = oNext.Anchor.String
 +
Wend
 +
End Sub
  
 
{{Manual}}
 
{{Manual}}

Revision as of 09:20, 13 February 2011


Keyboard shortcuts for fields

Here are some handy keyboard shortcuts to use when working with fields:

Ctrl+F2   Open the Fields dialog box.

Ctrl+F8   Field shadings on/off.

Ctrl+F9   Show/hide field names.

F9   Update fields.

Fixing the contents of fields

You can specify Fixed content for many items on the Document and DocInformation tabs so the field contents do not update. For example, you might use a field to insert the creation date of a document, and you would not want that date to change. In another place you might use a date field to show the current date, which you do want to change; in that case, deselect Fixed content when you insert the field.

Converting fields into text

Writer does not provide any easy way to convert field contents into text. To do this, you need to copy the field contents and paste them back as unformatted text. This is not a very good solution if you have hundreds of fields that you want to change, but you could use a macro to automate the process.

A suggested macro is provided as below. (Credits: JohnV from Openoffice Forums)

Sub FieldsToText oDoc = ThisComponent oFields = oDoc.getTextFields oEnum = oFields.createEnumeration While oEnum.hasMoreElements

oNext = oEnum.nextElement 
oNext.Anchor.String = oNext.Anchor.String 

Wend End Sub

Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools