Hallo,
Ik ben onwijs goed geholpen met een code die een sheet verstuurd:
Maar ik zou graag willen dat de bestandsnaam aangepast wordt naar de inhoud van een cel.
Bijvoorbeeld Tab1 CelA1
Hoe kan ik dit doen?
Ik ben onwijs goed geholpen met een code die een sheet verstuurd:
PHP:
Sub Mail_ActiveSheet()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String
Dim strbody As String
Dim cell As Range
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
Sheets("Lijst").Copy
Set Destwb = ActiveWorkbook
With Destwb
FileExtStr = ".txt": FileFormatNum = -4158
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = "Export"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
With OutMail
For Each cell In ThisWorkbook.Sheets("StartPagina").Range("C53:C60")
If cell.Value Like "?*@?*.?*" And LCase(cell.Offset(0, 1).Value) = "ja" Then
If strto = "" Then strto = stro & ";"
strto = strto & cell.Value & ";"
End If
Next cell
.To = strto
.CC = ""
.BCC = ""
.Subject = "Export Medewerkers Uren"
For Each cell In ThisWorkbook.Sheets("Kies").Range("D1:D60")
strbody = strbody & cell.Value & vbNewLine
Next
.body = strbody
.Attachments.Add Destwb.FullName
.Display
End With
On Error GoTo 0
.Close savechanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Maar ik zou graag willen dat de bestandsnaam aangepast wordt naar de inhoud van een cel.
Bijvoorbeeld Tab1 CelA1
Hoe kan ik dit doen?