Sviluppare funzionalita su Microsoft Office con VBA Errore Strano in PrintOut di un foglio

Login Registrati
Stai vedendo 4 articoli - dal 1 a 4 (di 4 totali)
  • Autore
    Articoli
  • #20927 Score: 0 | Risposta

    PMC77
    Partecipante
      18 pts

      Buongiorno a tutti!

      Fino a prima di aggiungere due if per fare o non fare stampare alcuni valori funzionava tutto!

      Ora mi va in errore!

      Errore che genera

      Boh???

      Private Sub CommandButtonDownload_Click()
      
      Dim IndexMP As Integer
      
      Dim WNet As Object
      
      Dim N As Integer
      
      Dim shPC As Worksheet
      Set shPC = ThisWorkbook.Sheets("Stampa1")
      
      Dim shPP As Worksheet
      Set shPP = ThisWorkbook.Sheets("Stampa2")
      
      Dim shPT As Worksheet
      Set shPT = ThisWorkbook.Sheets("Stampa3")
      
      Dim shTE As Worksheet
      Set shTE = ThisWorkbook.Sheets("Stampa4")
      
      'Discrimina su quale Multipage si sta Operando per lanciare la Stampa Corretta --> (Contabilità-Paghe-Tecnico)
      IndexMP = UserForm2.MultiPage1.Value
      
      If IndexMP = 0 Then
      'Tessera
      shTE.Range("C12").Value = UserForm2.TextBox1.Value
      shTE.Range("G12").Value = UserForm2.TextBox156.Value
      shTE.Range("C15").Value = UserForm2.TextBox157.Value
      shTE.Range("C17").Value = UserForm2.ComboBoxTT.Value
      shTE.Range("C19").Value = UserForm2.ComboBoxTOP.Value
      'GestioneOption Button
      If UserForm2.OptionButtonTACSi.Value = True Then
      shTE.Range("G15").Value = " X - SI"
      shTE.Range("H15").Value = " - NO"
      Else
      shTE.Range("G15").Value = " - SI"
      shTE.Range("H15").Value = " X - NO"
      End If
      If UserForm2.OptionButtonTAllSi.Value = True Then
      shTE.Range("G17").Value = " X - SI"
      shTE.Range("H17").Value = " - NO"
      Else
      shTE.Range("G17").Value = " - SI"
      shTE.Range("H17").Value = " X - NO"
      End If
      If UserForm2.OptionButtonTTraSi.Value = True Then
      shTE.Range("G19").Value = " X - SI"
      shTE.Range("H19").Value = " - NO"
      Else
      shTE.Range("G19").Value = " - SI"
      shTE.Range("H19").Value = " X - NO"
      End If
      shTE.Range("C24").Value = UserForm2.TextBox161.Value
      shTE.Range("C26").Value = UserForm2.TextBox160.Value
      shTE.Range("C27").Value = UserForm2.TextBox159.Value
      
      'Impostazione Pagina
      With shTE.PageSetup
      .PrintTitleRows = ""
      .PrintTitleColumns = ""
      .PrintArea = ""
      .LeftHeader = ""
      .CenterHeader = ""
      .RightHeader = ""
      .LeftFooter = ""
      .CenterFooter = ""
      .RightFooter = ""
      .LeftMargin = Application.InchesToPoints(0.33)
      .RightMargin = Application.InchesToPoints(0.33)
      .TopMargin = Application.InchesToPoints(0.5)
      .BottomMargin = Application.InchesToPoints(0.5)
      .HeaderMargin = Application.InchesToPoints(0.25)
      .FooterMargin = Application.InchesToPoints(0.25)
      .PrintHeadings = False
      .PrintGridlines = False
      .PrintComments = xlPrintNoComments
      .PrintQuality = 300
      .CenterHorizontally = True
      .CenterVertically = True
      .Orientation = xlLandscape
      .Draft = False
      .PaperSize = xlPaperA4
      .FirstPageNumber = xlAutomatic
      .Order = xlDownThenOver
      .BlackAndWhite = True
      .Zoom = False
      .FitToPagesWide = 1
      .FitToPagesTall = 1
      End With
      
      'Reale Stampa Foglio
      shTE.PrintOut
      
      End Sub
      #20931 Score: 0 | Risposta

      tanimon
      Partecipante
        16 pts

        ciao a tutti,

        ciao PMC

        per evitare questo tipo di inconvenienti, ti conviene imparare ad indentare il codice.

        Se provi, sono convinto che l'errore lo trovi da solo.

        Buon lavoro

        ciao

        Frank

        #20934 Score: 0 | Risposta

        PMC77
        Partecipante
          18 pts

          Purtroppo il problema non è il discorso indentatura!

          In allegato il file corretto (come su mio codice VBA)

          Tanto è vero che fino a poco fa (senza alcuni campi che vengono caricati) funzionava!

          Vedi allegato

          Allegati:
          You must be logged in to view attached files.
          #20941 Score: 0 | Risposta

          tanimon
          Partecipante
            16 pts

             

            PMC77 ha scritto:

            Purtroppo il problema non è il discorso indentatura!
             

             

            Non guardo file di testo, se vuoi allega un file di excel

            Forse mi sono spiegato male.

            l'indentatura NON rislve il problema, ti aiuta a vederlo.

             

          Login Registrati
          Stai vedendo 4 articoli - dal 1 a 4 (di 4 totali)
          Rispondi a: Errore Strano in PrintOut di un foglio
          Gli allegati sono permessi solo ad utenti REGISTRATI
          Le tue informazioni: