Hi Jörg,
the_style =
ThisComponent.getStyleFamilies.getByName("ParagraphStyles").getByName("jms1")
ThisComponent.getStyleFamilies.getByName("ParagraphStyles").insertByName("jms3",
the_style)>
i think you have to copy all Properties from old to new style.
this should work for Pagestyles:
REM ***** BASIC *****
OPTION EXPLICIT
Sub PageStyle
On Local Error Goto ErrorHandler
Dim oDocument as Object
Dim oSheet as Object
Dim oPStyle as Object
Dim oStyles as Object
Dim oCpyStyle as Object
Dim aProperties as Object
Dim vTmp as Variant
Dim sCopy as String
Dim sX as String
Dim i as Integer
oDocument = ThisComponent
oSheet = oDocument.getSheets.getByIndex(0)
oStyles = oDocument.StyleFamilies.getByName("PageStyles")
oPStyle = oStyles.getByName("Default")
sCopy = "NewStyle"
oCpyStyle = oDocument.createInstance("com.sun.star.style.PageStyle")
If oStyles.hasByName(sCopy) Then
oStyles.removeByName(sCopy)
EndIf
oStyles.insertByName(sCopy, oCpyStyle)
oSheet.PageStyle = oCpyStyle.Name
aProperties = oPStyle.PropertySetInfo.Properties
For i = LBound(aProperties) to UBound(aProperties)
sX = aProperties(i).Name
If Not IsNull(sX) Then
If sX <> "" Then
If oPStyle.getPropertyState(sX) =
com.sun.star.beans.PropertyState.DIRECT_VALUE Then
vTmp = oPStyle.getPropertyValue(sX)
oCpyStyle.setPropertyValue(sX, vTmp)
EndIf
EndIf
EndIf
Next i
Exit Sub
ErrorHandler:
msgbox Erl & Error & Err
Resume Next
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]