We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

UNO: change page style? [closed]

asked 2015-08-16 16:47:47 +0200

Hi-Angel gravatar image

updated 2015-08-22 08:42:48 +0200

Alex Kemp gravatar image

I'm trying to set the first page style to, well… «First page» ☺

But I couldn't get it work. E.g. supposing the file is the current document, then:

>>> cursor = file.Text.createTextCursor()
>>> cursor.setPropertyValue("PageStyleName", "First Page")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
__main__.PropertyVetoException: Property is read-only: 'PageStyleName

Why is this? What am I supposed to do? I also found that the property appears for enumerating paragraphs, however attempt to change it there ends the same way for me.

[edit: removed redundant tag]

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-08-23 20:14:42.611698

1 Answer

Sort by » oldest newest most voted

answered 2015-08-16 21:29:44 +0200

Hi-Angel gravatar image

In the end I am again figured it out by myself ☺ The page style could be set for a paragraph with the property «PageDescName». So I wrote a function in python — it accepts the opened document as a "file", and just changes the style name of the very first paragraph. Works like a charm.

def setFirstPage(file):
    """Sets the first page style to «First Page»"""
    enumeration = file.Text.createEnumeration()
    enumeration.nextElement().PageDescName = 'First Page'
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-08-16 16:47:47 +0200

Seen: 424 times

Last updated: Aug 22 '15