Goedenavond,
Ik heb de onderstaande code in mijn bestand staan.
hiermee verzend ik een mail uit het excel bestand.
Ik heb alleen een probleem met het gedeelte dat in het rood staat. In de betreffende cel waar Cells(3, 50) naar verwijst staat een tijd, alleen in de mail komt de tijd in getal notatie te staan.
hoe kan ik het zo aanpassen dat er toch een tijd komt te staan in de tekst van de mail?
Ik heb de onderstaande code in mijn bestand staan.
hiermee verzend ik een mail uit het excel bestand.
Ik heb alleen een probleem met het gedeelte dat in het rood staat. In de betreffende cel waar Cells(3, 50) naar verwijst staat een tijd, alleen in de mail komt de tijd in getal notatie te staan.
hoe kan ik het zo aanpassen dat er toch een tijd komt te staan in de tekst van de mail?
Code:
Sub MailErReport()
Dim oApp As Object
Dim oMail As Object
Dim LWorkbook As Workbook
Dim LFileName As String
'Turn off screen updating
Application.ScreenUpdating = False
'Copy the active worksheet and save to a temporary workbook
Sheets(Array("ER ", "Afhandeling")).Copy
Set LWorkbook = ActiveWorkbook
'Create a temporary file in your current directory that uses the name
' of the sheet as the filename
LFileName = "ER " & Cells(2, 8) & " " & Cells(22, 21) & ".xls"
On Error Resume Next
'Delete the file if it already exists
Kill LFileName
On Error GoTo 0
'Save temporary file
LWorkbook.SaveAs Filename:=LFileName
'Create an Outlook object and new mail message
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
'Set mail attributes (uncomment lines to enter attributes)
' In this example, only the attachment is being added to the mail message
With oMail
.to = ""
.Subject = "ER " & Cells(2, 8) & " " & Cells(22, 21)
.Body = Cells(2, 90) & "," & vbCrLf & vbCrLf _
& "Bijgevoegd het ER : " & Cells(2, 8) & " plaats " & Cells(22, 21) & " om " & [COLOR="#FF0000"]Cells(3, 50)[/COLOR] & " uur." & vbCrLf & vbCrLf & vbCrLf _
& "_______________________________________ " & vbCrLf _
& "Real " & vbCrLf & vbCrLf _
& "With kind regards," & vbCrLf & vbCrLf _
& Cells(20, 59)
.Attachments.Add LWorkbook.FullName
.Display
End With
'Delete the temporary file and close temporary Workbook
LWorkbook.ChangeFileAccess Mode:=xlReadOnly
Kill LWorkbook.FullName
LWorkbook.Close savechanges:=False
'Turn back on screen updating
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub