Sviluppare funzionalita su Microsoft Office con VBA Stampa Unione casereccia con salvataggio di ogni pdf "creato" –> HELP

Login Registrati
Stai vedendo 1 articolo (di 1 totali)
  • Autore
    Articoli
  • #23890 Score: 0 | Risposta

    PMC77
    Partecipante
      18 pts

      Buongiorno a tutti!

      qualcuno si è già cimentato in una sorta di "Stampa Unione" casereccia con salvataggio in Pdf dei vari files ottenuti in diverse cartelle?

      Io ho abbozzato una roba tipo questa...

      Sub CreaPDF()
         
          Dim oApp As Application
          Dim oDoc As DocumentInspector
         
          Dim DestFile As String
          Dim DestPath As String
         
          Dim Row As Integer
          Dim RowMax As Integer
                 
          Dim ShPECU As Worksheet
          Set ShPECU = ThisWorkbook.Worksheets("DatiPerInvioPECU")
                 
          'Ciclo sul Foglio PECU
          DestPath = "c:\Pippo"
          Row = 2
          RowMax = 150
          While Row <= RowMax And ShPECU.Range("A" & Row).Value <> ""
             
              'Per ogni riga genera un Pdf nella cartella corretta con i Dati Specifici (Tipo stampa Unione)
              Set oApp = GetObject(, "Word.Application")
              If oApp Is Nothing Then
                  Set oApp = New Word.Application
              End If
              With oApp
                  .Visible = True
                  Set oDoc = .Documents.Open("c:\pippo\lettera.doc")                             'Apertura Documento Word
                  .Selection.Goto What:=wdGoToBookmark, Name:="Class"
                  .Selection.Delete Unit:=wdCharacter, Count:=1
                  .Selection.InsertAfter ShPECU.Range("F" & Row).Value
                  .Selection.Goto What:=wdGoToBookmark, Name:="Dirigente"
                  .Selection.Delete Unit:=wdCharacter, Count:=1
                  .Selection.InsertAfter ShPECU.Range("G" & Row).Value
                  .Selection.Goto What:=wdGoToBookmark, Name:="FraseOggetto"
                  .Selection.Delete Unit:=wdCharacter, Count:=1
                  .Selection.InsertAfter ShPECU.Range("E" & Row).Value
                  'Salva in Pdf
                  DestFile = DestPath & "\" & Left(ShPECU.Range("A" & Row).Value, 1) & "_" &   ShPECU.Range("B" & Row).Value & "Lettera"
                  oDoc.ExportAsFixedFormat OutputFilename:=DestFile & "" & s & ".pdf", ExportFormat:=17
                  oDoc.Close True                                                                                                                                                                                                                 'Dhiusura Documento
                  .Quit                                                                                                                                                                                                                           'Chiusura Applicazione
                        
              End With
             
              Set oDoc = Nothing                    ' Libera (disalloca) la Memoria
              Set oApp = Nothing                    ' Libera (disalloca) la Memoria
             
              'Incrementa la Riga
              Row = Row + 1
             
          Wend
      End Sub

    Login Registrati
    Stai vedendo 1 articolo (di 1 totali)
    Rispondi a: Stampa Unione casereccia con salvataggio di ogni pdf "creato" –> HELP
    Gli allegati sono permessi solo ad utenti REGISTRATI
    Le tue informazioni: