Adattare codice salva PDF
Hai un problema con Excel? 
Adattare codice salva PDF
di PAGANIVA (utente non iscritto) data: 16/08/2017 21:30:20
Saluti a tutti.
Avrei la necessità di adattare una macro che salva i dati contenuti in un foglio excel in formato PDF.
La difficoltà consiste nel fatto che vorrei fosse salvata sono una parte dei dati e nello specifico.
Partendo dalla seconda riga i dati contenuti dalla colonna C alla Colonna AA fino all'ultima riga piena contenuta sempre in colonna C.
Spero di essermi spiegato, allego comunque un file dove è evidenziato il risultato voluto.
Grazie anche a chi è ancora in vacanza.
Sub Salva_PDF()
' SALVA IN PDF
Dim Delimita As Integer
Dim sPath As String
Dim sNome As String
Application.DisplayAlerts = False
'On Error Resume Next
With ThisWorkbook
sPath = .Path
With .Worksheets(1) ' il Foglio 1 del file excel
sNome = Format(.Range("C2").Value) & " range al " & Format(.Range("F1").Value, "DD-MM-YYYY")
Delimita = Cells(2, 3).End(xlDown).Row
'il 2 indica la riga mentre il 3 la colonna dove si trova l'ultima cella piena
Range(Cells(2, 3), Cells(Delimita, 27)).Select 'arriva alla colonna AA
' il 27 indica l'ultima colonna che seleziona AA in base alla mia esigenza, ma credo sia
' da adattare l'istruzione successiva in quanto salva tutto in PDF e non la zona evidenziata
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sPath & "" & sNome & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "File " & sPath & "" & sNome & " salvato", vbInformation, " PDF "
End With
Exit Sub
End With
Range("c2").Select
Application.DisplayAlerts = True
End Sub |
di patel data: 17/08/2017 07:32:46
prova così
Sub Salva_PDF()
' SALVA IN PDF
Dim Delimita As Integer
Dim sPath As String
Dim sNome As String
Application.DisplayAlerts = False
'On Error Resume Next
sPath = ThisWorkbook.Path
Worksheets(1).Activate ' il Foglio 1 del file excel
sNome = Format(Range("C2").Value) & " range al " & Format(Range("F1").Value, "DD-MM-YYYY")
Delimita = Cells(2, 3).End(xlDown).Row
'il 2 indica la riga mentre il 3 la colonna dove si trova l'ultima cella piena
Range(Cells(2, 3), Cells(Delimita, 27)).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sPath & "" & sNome & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
MsgBox "File " & sPath & "" & sNome & " salvato", vbInformation, " PDF "
Range("c2").Select
Application.DisplayAlerts = True
End Sub
|
di PAGANIVA (utente non iscritto) data: 21/08/2017 22:16:59
Ok tutto funziona grazie patel
Vuoi Approfondire?