Sub Dotch()
Plaats = "C:\JVC\Contracten\"
Naam = Range("O1").Value
adres = Range("O10").Value
handtekening = vbLf _
& vbLf _
& "Met vriendelijke groet," & vbLf _
& "Ann"
If Dir(Plaats & Naam & ".pdf") <> "" Then
antwoord = MsgBox("Het bestand: " & Naam & ".pdf bestaat reeds Vervangen?", vbYesNo)
If antwoord = vbYes Then
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Plaats & Naam & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, to:=1, OpenAfterPublish:=False
Else
GoTo verder
End If
Else
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Plaats & Naam & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, From:=1, to:=1, OpenAfterPublish:=False
End If
verder:
Bestand = ThisWorkbook.Path & "\" & Range("O1").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Bestand
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = adres
.Body = handtekening
.Attachments.Add Bestand
.Display
End With
Kill (Bestand)
End Sub
Checken als de folder bestaat vind ik persoonlijk wat overkill.