Potrei eliminare l'anteprima di stampa dal menu Strumenti-Personalizza ma è ovvio che chi ne capisce un poco riesce a rimettere l'anteprima molto facilmente. Esiste la possibilità di impedire di rimettere sia la stampa che il Mostra Fogli dal menu Formato?
La macro associata al pulsante di stampa è la seguente:
Codice: Seleziona tutto
dim document as object
dim dispatcher as object
dim objSheets as object
dim ArrayPrn(8) as new com.sun.star.beans.PropertyValue
Dim PrnOptn(5) as new com.sun.star.beans.PropertyValue
Dim sMessaggio As String
sMessaggio = " REGISTRARE E STAMPARE "
If MsgBox (sMessaggio, 292, " Attenzione! L'ASSEVERAZIONE VERRA' REGISTRATA ") = 6 Then
End Sub
'-------------------------------------------------'
objSheets = ThisComponent.Sheets ' CONTENITORE GRUPPO SHEETS FOGLIO CALC CORRENTE
' ArrayPrn = ThisComponent.GetPrinter ' ACQUISISCI L'IMPOSTAZIONE
ArrayPrn(0).Name = "Name" ' PROPRIETA' NOME DELLA STAMPANTE
ArrayPrn(0).Value = "Adobe PDF" ' IMPOSTA NOME DELLA STAMPANTE
ThisComponent.SetPrinter(ArrayPrn) ' IMPOSTA LA STAMPANTE
PrnOptn(0).Name = "CopyCount" ' IMPOSTA L'OPZIONE DI STAMPA CopyCount
PrnOptn(0).Value = 1 ' IMPOSTA IL VALORE PER CopyCount
' PrnOptn(1).Name = "FileName"
' PrnOptn(1).Value = "W:\PROCEDUR\OpenOffice\Vari\Prova.pdf"
PrnOptn(5).Name = "Wait" ' IMPOSTA L'OPZIONE Wait
PrnOptn(5).Value = True ' IMPOSTA SU ATTENDI OK DA STAMPA PER RIENTRARE IN Calc
For I = 0 to objSheets.Count - 1
if objSheets.getByName(objSheets.elementNames(I)).isVIsible = False then ' IF SHEET NASCOSTO
objSheets.getByName(objSheets.elementNames(I)).isVIsible = True ' LO SCOPRO
ThisComponent.Currentcontroller.setActiveSheet(objSheets.getByName(objSheets.elementNames(I)) ' LO RENDO ATTIVO E CORRENTE
document = ThisComponent.CurrentController.Frame ' ACQUISISCO L'OGGETTO FRAME
ThisComponent.Print(PrnOptn())
' For j = 0 to 100000: Next j
objSheets.getByName(objSheets.elementNames(I)).isVIsible = False ' NASCONDE LO SHEET STAMPATO
endif ' ENDIF
Next I ' NEXT SU ELENCO SHEETS
Dim DocName as object, DocUlr as string, dummy(), range as object
Doc = ThisComponent
Sheet = Doc.Sheets(5) ' 6° foglio del file contenete la macro
Range = Sheet.getCellRangeByName("B7:J7").getDataArray ' range da copiare
sFileName ="C:\Users\Lenovo\Desktop\Protocollo.ods" ' file destinazione
DocUrl = ConvertToURL(sFileName)
DocName = StarDesktop.loadComponentFromURL (DocUrl, "_blank",0, Dummy() )
Protocollo = DocName.Sheets(0)
Protocollo.unprotect("XXXXX")
Rem Trova prima riga vuota in colonna A
Riga = 5
Do while DocName.Sheets(0).GetCellByposition(1,Riga).String <> ""
Riga = Riga + 1
Loop
Riga = Riga + 1
dRange = Protocollo.getCellRangeByName("B" & Riga & ":J" & Riga) ' range destinazione (PrimaRigaLibera)
dRange.setDataArray(Range)
Doc.Sheets(0).GetCellRangeByName("E6").Value = Protocollo.getCellRangeByName("A" & Riga).Value
Protocollo.protect("XXXXX")
DocName.store
DocName.Close(true)
End Sub