DeTovenaar
Gebruiker
- Lid geworden
- 23 dec 2010
- Berichten
- 10
Goedemorgen,
Ik wil via een macro een pdf versturen. Met de codes van www.rondebruin.nl lukt dit prima, alleen nu wil ik hierin ook een handtekening meesturen. Ik heb volgende code gebruikt maar dan krijg ik een foutmelding : Fout 5 tijdens uitvoering: "Ongeldige procedure-aanroep of ongeldig argument".
Weet iemand wat ik fout doe??
Ik wil via een macro een pdf versturen. Met de codes van www.rondebruin.nl lukt dit prima, alleen nu wil ik hierin ook een handtekening meesturen. Ik heb volgende code gebruikt maar dan krijg ik een foutmelding : Fout 5 tijdens uitvoering: "Ongeldige procedure-aanroep of ongeldig argument".
Weet iemand wat ik fout doe??
Code:
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub Mail_Outlook_With_Signature_Html()
' Don't forget to copy the function GetBoiler in the module.
' Working in Office 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3><B>Dear Customer</B></H3>" & _
"Please visit this website to download the new version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
"<br><br><B>Thank you</B>"
'Use the second SigString if you use Vista or win 7 as operating system
'SigString = "C:\Users\" & Environ("username") & _
"\AppData\Roaming\Microsoft\Signatures\My sig.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
On Error Resume Next
With OutMail
.To = "ron@debruin.nl"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody & "<br><br>" & Signature
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub