Sub SaveFileToPDF_Prompt()
If Range("Plan1!AK10") = 1 Then
ThisWorkbook.Sheets(Array("Folha1", "Plan1", "Resumo", "RAIRN", "TARN", "Q07F", "Q08G", "Q10GF", "PEC", "Folha3")).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, "Destination file exists!")
Case vbYes
Kill vPDFPath
Case vbNo
bRestart = True
Case vbCancel
Sheets("MInicial").Select
Exit Sub
End Select
End If
Loop Until bRestart = False
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=vPDFPath, _
OpenAfterPublish:=True
Sheets("MInicial").Select
MsgBox "Ficheiro Criado com Sucesso"
End If
End Sub
Postado : 03/02/2016 12:46 pm