questo č uno dei motodi dove eseguo il traciamento degli errori:
codice:
Private Sub Setta_FoglioMargini_PičPagina(ByVal Foglio As System.Object, ByVal Intestazione As String)
' setto la mia classe errori
ERRORI.INIZIA_Tracciatura("Errori durante il settaggio dei margini e pič pagina del foglio excel!..")
On Error GoTo Errori ' a ogni errore salta alla riga: Errori
' qua inizia tutto il codice per excel
With DirectCast(Foglio.PageSetup, Excel.PageSetup)
'.Application.ActiveWindow.View = Excel.XlWindowView.xlPageBreakPreview
.Application.PrintCommunication = False
.PrintTitleRows = ""
.PrintTitleColumns = ""
.Application.PrintCommunication = True
.Application.PrintCommunication = False
.PrintArea = ""
.Application.PrintCommunication = True
.Application.PrintCommunication = False
'.Orientation = Excel.XlPageOrientation.xlLandscape ' non supportata in vb.net
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = Intestazione
.RightFooter = ""
.Application.PrintCommunication = True
.Application.PrintCommunication = False
.LeftMargin = 0.25
.RightMargin = 0.25
.TopMargin = 0.3
.BottomMargin = 0.3
.HeaderMargin = 0
.FooterMargin = 0
.Application.PrintCommunication = True
.Application.PrintCommunication = False
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = Excel.XlPrintLocation.xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Draft = False
.PaperSize = Excel.XlPaperSize.xlPaperA4
.FirstPageNumber = -4105 ' equivale a : .xlAutomatic per vba
.Order = Excel.XlOrder.xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = Excel.XlPrintErrors.xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
.Application.PrintCommunication = True
End With
On Error GoTo 0 ' qua termina anche la tracciatura
Exit Sub
Errori: ' questa parte viene eseguita solo se si verifica uno o + errori
ERRORI.Add(Err) ' aggiungo l'errore alla mia classe
Resume Next ' ritorna as eseguire l'istruzione successiva
End Sub