- Format -> Page... -> Header -> Edit...
- For "Center Area" I insert following string (with fields <File Name> and <Sheet Name>): File: <File Name> / Page: <Sheet Name>
- The file name I set to be in bold and the rest of the text is regular text.
Code: Select all
Sub Snippet
Dim oStyleFamilies As Variant
Dim oObj1 As Variant
Dim oObj2 As Variant
Dim oRightPageHeaderContent As Variant
Dim oCenterText As Variant
Dim sString As String
Dim oTextFields As Variant
Dim nCount As Long
oStyleFamilies = ThisComponent.getStyleFamilies()
oObj1 = oStyleFamilies.getByName("PageStyles")
oObj2 = oObj1.getByName("Default")
oRightPageHeaderContent = oObj2.RightPageHeaderContent
oCenterText = oRightPageHeaderContent.getCenterText()
sString = oCenterText.getString() ' --> "File: ??? / Page: ???" (string used in the header with placeholders for the fields)
oTextFields = oCenterText.getTextFields()
nCount = oTextFields.getCount() ' --> "2" (number of fields used in the string)
End Sub
Code: Select all
<style:header>
<text:p>File:
<text:span text:style-name="MT1">
<text:file-name text:display="name-and-extension">
???</text:file-name>
</text:span>/ Page:
<text:sheet-name>???</text:sheet-name></text:p>
</style:header>