-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Matthias,

> Sorry, but your code copies even less. Header and footer are
> completely missing in the copied page style whereas with my code

yes you are right, i found some errors too :-(
but this should hopefully work for *spreadsheet*' documents:

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


- --

GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHaA9hTiyrQM/QSkURAnSLAJ4/CO4sez1h5GkOXMKn5Jw7gY/VzQCgnmvz
tRbjzMJux/POXsKav3bbSAo=
=ScrY
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to