Sub Salvar_PDF()
Application.ScreenUpdating = False
If Range("Cliente!AQ5") = 1 Then
Sheets("MenuInicial").Select
ThisWorkbook.Sheets(Array("Capa", "Cliente", "ResumoRn1", "Rn1", "TribAut", "Q07F", "Q08", "Q10F", "PEC", "Benefícios")).Select
Dim vPDFPath As Variant
Do
bRestart = False
vPDFPath = Application.GetSaveAsFilename(, "PDF Files (*.pdf), *.pdf")
If CStr(vPDFPath) = "False" Then
Exit Sub
Else
lAppSep = InStrRev(vPDFPath, Application.PathSeparator)
End If
If UCase(Dir(vPDFPath)) = UCase(Right(vPDFPath, Len(vPDFPath) - lAppSep)) Then
Select Case MsgBox("O arquivo já existe. Deseja substituí-lo?", _
vbYesNoCancel, "ATENÇÃO!")
Case vbYes
Kill vPDFPath
Case vbNo
bRestart = True
Case vbCancel
Sheets("MenuInicial").Select
Exit Sub
End Select
End If
Loop Until bRestart = False
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=vPDFPath, _
OpenAfterPublish:=True
Sheets("MenuInicial").Select
MsgBox "Ficheiro Criado com Sucesso"
End If
End sub
Bookmarks