Ciao Domenico,
Ciao Norman, ti scrivo per chiedere di nuovo il tuo aiuto.
Volevo aggiungere al codice che hai fatto sopra, lo possibilità di stampare.
Però deve stampare cartaceo (no PDF) soltanto 2 foglio dei tre presenti (Foglio1, Foglio 2, Foglio3) nella cartella di lavoro.
Prova qualcosa del genere:
'=========>>
Option Explicit
'--------->.
Public Sub StampareFogli()
Dim WB As Workbook
Dim SH As Worksheet
Dim sPath As String, sStr As String, sFileName As String
Dim sCliente As String, sData As String
Dim sNumeroFattura As String
Dim arrFogli As Variant
Const cPrefix As String = "FT("
Const cTesto As String = ") del "
Const cPath As String =
"**C:\Utenti\Domenico\Documenti**" '<<=== Modifica
Const cCellaNomeCliente As String = "A1" '<<=== Modifica
Const cCellaData As String = "E1" '<<=== Modifica
Const cCellaNumeroFattura As String = "E2" '<<=== Modifica
Const sFogliDaStampare As String = "Foglio1,Foglio3" '<<=== Modifica
Set WB = ThisWorkbook
Set SH = ActiveSheet
With SH
sCliente = .Range(cCellaNomeCliente).Value
sData = Format(.Range(cCellaData).Value, "dd-mm-yyyy")
sNumeroFattura = .Range(cCellaNumeroFattura).Value
On Error GoTo ErrHandler
With Application
sStr = .PathSeparator
If Right(cPath, 1) = sStr Then
sPath = cPath
Else
sPath = cPath & sStr
End If
End With
End With
sFileName = cPrefix & sNumeroFattura & cTesto _
& sData & " (" & sCliente & ")"
On Error GoTo ErrHandler
arrFogli = Split(sFogliDaStampare, ",")
WB.Sheets(arrFogli).PrintOut
Exit Sub
ErrHandler:
Call MsgBox(Prompt:="Errore " _
& Err.Number _
& " (" _
& Err.Description _
& ") nella routine: SalvaInPDF_1", _
Buttons:=vbCritical, _
Title:="ERRORE")
End Sub
'<<=========
===
Regards,
Norman