Guido (email.it) ha scritto:
zot...
qualcuno mi da un dritta su come fare da macro la copia di uno stile pagina,

Scusa Quido... dimenticavo.

Io richiamo le due sub dall'interno di un'altra macro... forse è meglio che ti posto il codice completo!

L'ho risistemato un po' e dovrebbe funzionare anche fuori da Ultimus.

ciao

Bart

REM  *****  BASIC  *****
global print_area
public sStile_Pag
public oAktPage

SUB Duplica_Sheet_new_doc
' ' Shortcut: Ctrl-Alt-Q (in NUOVO doc)
dim nEndRow as long
dim nEndCol as long
'print "duplico la sheet in nuovo doc"
if ThisComponent.getCurrentController._
 getFrame.LayoutManager.isElementVisible _
  ( "private:resource/toolbar/previewbar" ) Then
Msgbox "Prima chiudi l'anteprima di stampa! ",16
exit sub : End If

oSheet = ThisComponent.currentcontroller.activesheet
lnumSheet=oSheet.RangeAddress.Sheet
sOK = "OK"
' questo serve solo a rendere la var not isMissing...????       
sNomeBuono =    DuplicaSheetinDoc (sOK, lnumSheet)
if sNomeBuono <> "prosegui" then
                exit sub
end if

sTempSheet=ThisComponent.currentcontroller.activesheet.name
oSheet = ThisComponent.currentController.activeSheet
print_area= oSheet.getPrintAreas
' registro l'area di stampa
RepeatRows = oSheet.getTitleRows
 'registro le righe da ripetere (intestazione colonna)
PrintRepeatRows = oSheet.PrintTitleRows
'       print RepeatRows
'>>>>>>>>>>>>>>>>>
Copy_PageStyle
'<<<<<<<<<<<<<<<<<
oCell = oSheet.GetCellbyPosition( 0, 0 )
oCursor = oSheet.createCursorByRange(oCell)
oCursor.GotoEndOfUsedArea(True)
aAddress = oCursor.RangeAddress
nEndRow = aAddress.EndRow
nEndCol = aAddress.EndColumn    
oRange = oSheet.getCellRangeByPosition (0,0,245,nEndRow+30)
Flags = com.sun.star.sheet.CellFlags.FORMULA + _
                com.sun.star.sheet.CellFlags.OBJECTS
aSaveData = oRange.getDataArray()
'Questa linea salva i dati delle varie celle prima
' di cancellare le formule altrimenti
'una volta cancellate le relative celle
' risulterebbero vuote
oRange.clearContents(Flags)
oRange.setDataArray( aSaveData )
' rimette tutti i dati nelle rispettive celle

dim dispatcher as object
oDocumento = ThisComponent
oDoc = ThisComponent.CurrentController.Frame
sNomeSheet = ThisComponent.currentcontroller.activesheet.name
sUrl1 = oDocumento.Url
dispatcher=createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Name"
args1(0).Value = sNomeSheet
dispatcher.executeDispatch(oDoc,".uno:JumpToTable","",0,args1())

dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "DocName"
args2(0).Value = ""
args2(1).Name = "Index"
args2(1).Value = 32767
args2(2).Name = "Copy"
args2(2).Value = true
dispatcher.executeDispatch(oDoc,".uno:Move", "",0,args2())
oDocumento.Sheets.RemoveByName(sTempSheet)

oSheet = ThisComponent.Sheets.getByName(_
ThisComponent.currentcontroller.activesheet.name)
'>>>>>>>>>>>>>>>>>>>>>>>>>
Write_PageStyle
'<<<<<<<<<<<<<<<<<<<<<
'Visualizza_PageBreak
oSheet.setPrintAreas(print_area)
oSheet.setTitleRows(RepeatRows)
oSheet.setPrintTitleRows(PrintRepeatRows)

Msgbox "Questa tabella � stata CONSOLIDATA" & _
 "ed esportata come nuovo Documento..."
END SUB



SUB Copy_PageStyle
oSheet = ThisComponent.Sheets.getByName(_
ThisComponent.currentcontroller.activesheet.name)
sStile_Pag = oSheet.PageStyle
'xray sStile_Pag
'registra lo stile corrente della Sheet
oDesktop = createUnoService( "com.sun.star.frame.Desktop" )
oController = oDesktop.CurrentFrame.Controller
oDocument = oController.Model
  oStyleFam = oDocument.StyleFamilies
' xray oStyleFam
  oTablePageStyles = oStyleFam.getbyName("PageStyles")
  oAktPage = oTablePageStyles.getByname(sStile_Pag)
  aProperties = oAktPage.PropertySetInfo.Properties
END SUB



SUB Write_PageStyle
oSheet = ThisComponent.Sheets.getByName(_
ThisComponent.currentcontroller.activesheet.name)
oDocument = thiscomponent
oStyleFam = oDocument.StyleFamilies
oTablePageStyles = oStyleFam.getbyName("PageStyles")
oCpyStyle=oDocument.createInstance("com.sun.star.style.PageStyle")
if sStile_Pag <> "Default"  then
oTablePageStyles.insertByName(sStile_Pag, oCpyStyle)
aProperties =  oAktPage.PropertySetInfo.Properties

 For i = LBound(aProperties) to UBound(aProperties)
     sX = aProperties(i).Name
     If  oAktPage.getPropertyState(sX)=_
    com.sun.star.beans.PropertyState.DIRECT_VALUE Then
        vTmp =  oAktPage.getPropertyValue(sX)
        oCpyStyle.setPropertyValue(sX, vTmp)
     EndIf
  Next i
  oSheet.PageStyle = sStile_Pag
'imposta lo stile duplicato come corrente
end if
END SUB

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

Rispondere a