Even een kort vraagje.
Is de rode regel in de code, echt noodzakelijk?(de 3de laatste regel)
Is de rode regel in de code, echt noodzakelijk?(de 3de laatste regel)
Code:
Private Sub CommandButton10_Click() 'Mailen
If ComboBox1.Value = "" Then
MsgBox ("Eerst op een naam klikken in de lijst."), vbCritical, "Fout!"
Exit Sub
End If
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Call wieter
With Sheets("Blad4")
FileNamePDF = Environ("temp") & "\" & .Name & Format(Now, "_DDMMYYYYHHMMSS") & ".pdf"
.Range("A1:J63").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FileNamePDF
End With
StrTo = Sheets("Blad2").Range("I3")
StrSubject = Sheets(2).Range("N3")
StrBody = Sheets("Blad2").Range("N6") & vbNewLine & Sheets("Blad2").Range("N7") & ComboBox1.Value _
& vbNewLine & Sheets("Blad2").Range("N8") & vbNewLine & Sheets("Blad2").Range("N9")
With OutMail
.To = StrTo
.Subject = StrSubject
.Body = StrBody
.Attachments.Add FileNamePDF
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
[COLOR="#FF0000"] Kill FileNamePDF[/COLOR]
MsgBox ("De mail is verzonden."), , "Verzonden"
End Sub