Goedemorgen,
Ik heb onderstaande code gevonden op het internet en deze in een module in mijn werkmap geplaatst.
Zoals ik het begrijp zal de code sheet 1 van de werkmap naar de 4 e-mail adressen sturen.
Dat lukt niet , ik krijg een fout melding.
De rode tekst is de foutmelding.
Hoe kan ik dit oplossen.
Bij voorbaat dank
Gr Ronsom
Ik heb onderstaande code gevonden op het internet en deze in een module in mijn werkmap geplaatst.
Code:
Sub Mail_Sheets()
'For Tips see: http://www.rondebruin.nl/win/winmail/div/tips.htm
'Working in Excel 2000-2016
Dim wb As Workbook
Dim Shname As Variant
Dim Addr As Variant
Dim N As Integer
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim I As Long
Shname = Array("Sheet1")
Addr = Array("ron@test.nl", "jelle@test.nl", "judith@test.nl", "nicolet@test.nl")
If Val(Application.Version) >= 12 Then
'You run Excel 2007-2016
FileExtStr = ".xlsm": FileFormatNum = 52
Else
'You run Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
TempFilePath = Environ$("temp") & "\"
'Create the new workbooks/Mail it/Delete it
For N = LBound(Shname) To UBound(Shname)
TempFileName = "Sheet " & Shname(N) & " " & Format(Now, "dd-mmm-yy h-mm-ss")
ThisWorkbook.Sheets(Shname(N)).Copy
Set wb = ActiveWorkbook
With wb
[COLOR="#FF0000"].SaveAs TempFilePath & TempFileName & FileExtStr, FileFormatNum[/COLOR]
On Error Resume Next
For I = 1 To 3
.SendMail Addr(N), _
"This is the Subject line"
If Err.Number = 0 Then Exit For
Next I
On Error GoTo 0
.Close SaveChanges:=False
End With
'Delete the file you have send
Kill TempFilePath & TempFileName & FileExtStr
Next N
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Zoals ik het begrijp zal de code sheet 1 van de werkmap naar de 4 e-mail adressen sturen.
Dat lukt niet , ik krijg een fout melding.
De rode tekst is de foutmelding.
Hoe kan ik dit oplossen.
Bij voorbaat dank
Gr Ronsom