Originally Posted by
fumei
You are not using Option Explicit? I suspect you are not because the code below:[vba]
Public Sub MailBody()
MsgMail = "Sehr geehrte Damen und Herren" & vbCrLf & _
"Dear ladies and gentlemen." & vbCrLf & " " & vbCrLf & _
"Enclosed you will find your monthly account statement. Please check the content" & vbCrLf & _
"of the statement(s) and let us know if you have questions to our data." & _
vbCrLf & " " & vbCrLf & vbCrLf & " " & vbCrLf & _
"Kind regards" & vbCrLf & " & vbCrLf & _
End Sub
[/vba]should fail as it is incorrect syntax - that last & _ needs to be followed by something.
Declare it once in a standard module. If it is declared as Public then it can be used anywhere in the project. Of course you must, again, run your procedure to give it a value first, before you use it.
Again, though, as it is simply a string, WHY execute a procedure to give the same value everytime. Declare it as a CONSTANT.[vba]
Public Const MsgMail As String = "Sehr geehrte Damen und Herren" & _
vbCrLf & "Dear ladies and gentlemen." & vbCrLf & " " & _
vbCrLf & "Enclosed you will find your monthly account statement. " & _
"Please check the content" & vbCrLf & _
"of the statement(s) and let us know if you have questions to our data." & _
vbCrLf & " " & vbCrLf & vbCrLf & " " & vbCrLf & _
"Kind regards" & vbCrLf & vbCrLf
[/vba]without that extra & _
Now it can be used anywhere.
[vba].Body = MsgMail
[/vba]will simply get the value of MsgMail, defined as a constant.