S
Seanie
I am trying to create a string of text to place in the message body of
an e-mail. Using Ron De Bruins code I've run in to the "Too many line
continuations". I've a requirement for 31 lines, but it hits this
error on line 24. How can I combine 2 text strings to appear in the
message body of the reports. My code with only the first stringbody
is:-
Sub Mail_New_Version()
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 sh As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
ActiveWindow.TabRatio = 0.908
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
For Each cell In ThisWorkbook.Sheets("Report").Range("BJ1:BJ25")
strbody = strbody & cell.Value & vbNewLine
Next
strbody1 = ThisWorkbook.Sheets("Master").Range("E1").Value & _
ThisWorkbook.Sheets("Master").Range("E2").Value & _
ThisWorkbook.Sheets("Master").Range("E3").Value & _
ThisWorkbook.Sheets("Master").Range("E4").Value & _
ThisWorkbook.Sheets("Master").Range("E5").Value & _
ThisWorkbook.Sheets("Master").Range("E6").Value & " " &
ThisWorkbook.Sheets("Report").Range("B62").Value & _
ThisWorkbook.Sheets("Master").Range("E7").Value & " " &
ThisWorkbook.Sheets("Report").Range("B63").Value & _
ThisWorkbook.Sheets("Master").Range("E8").Value & " " &
ThisWorkbook.Sheets("Report").Range("B64").Value & _
ThisWorkbook.Sheets("Master").Range("E9").Value & _
ThisWorkbook.Sheets("Master").Range("E10").Value & _
ThisWorkbook.Sheets("Master").Range("E11").Value & " " &
ThisWorkbook.Sheets("Report").Range("B33").Value & _
ThisWorkbook.Sheets("Master").Range("E12").Value & " " &
ThisWorkbook.Sheets("Report").Range("B34").Value & _
ThisWorkbook.Sheets("Master").Range("E13").Value & " " &
ThisWorkbook.Sheets("Report").Range("B35").Value & _
ThisWorkbook.Sheets("Master").Range("E14").Value & _
ThisWorkbook.Sheets("Master").Range("E15").Value & _
ThisWorkbook.Sheets("Master").Range("E16").Value & " " &
ThisWorkbook.Sheets("Report").Range("B56").Value & _
ThisWorkbook.Sheets("Master").Range("E17").Value & " " &
ThisWorkbook.Sheets("Report").Range("B57").Value & _
ThisWorkbook.Sheets("Master").Range("E18").Value & " " &
ThisWorkbook.Sheets("Report").Range("B58").Value & _
ThisWorkbook.Sheets("Master").Range("E19").Value & _
ThisWorkbook.Sheets("Master").Range("E20").Value & _
ThisWorkbook.Sheets("Master").Range("E21").Value & " " &
ThisWorkbook.Sheets("Report").Range("B49").Value & _
ThisWorkbook.Sheets("Master").Range("E22").Value & " " &
ThisWorkbook.Sheets("Report").Range("B50").Value & _
ThisWorkbook.Sheets("Master").Range("E23").Value & " " &
ThisWorkbook.Sheets("Report").Range("B51").Value & _
ThisWorkbook.Sheets("Master").Range("E24").Value & " " &
ThisWorkbook.Sheets("Report").Range("B52").Value
With Destwb
On Error Resume Next
With OutMail
.To = ThisWorkbook.Sheets("Master").Range("B1").Value
.CC = ""
.BCC = ""
.Subject = ThisWorkbook.Sheets("Report").Range("B2").Value
.Body = strbody
.ReadReceiptRequested = False
.Importance = 1
.Send
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%S"
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
an e-mail. Using Ron De Bruins code I've run in to the "Too many line
continuations". I've a requirement for 31 lines, but it hits this
error on line 24. How can I combine 2 text strings to appear in the
message body of the reports. My code with only the first stringbody
is:-
Sub Mail_New_Version()
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 sh As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
ActiveWindow.TabRatio = 0.908
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
For Each cell In ThisWorkbook.Sheets("Report").Range("BJ1:BJ25")
strbody = strbody & cell.Value & vbNewLine
Next
strbody1 = ThisWorkbook.Sheets("Master").Range("E1").Value & _
ThisWorkbook.Sheets("Master").Range("E2").Value & _
ThisWorkbook.Sheets("Master").Range("E3").Value & _
ThisWorkbook.Sheets("Master").Range("E4").Value & _
ThisWorkbook.Sheets("Master").Range("E5").Value & _
ThisWorkbook.Sheets("Master").Range("E6").Value & " " &
ThisWorkbook.Sheets("Report").Range("B62").Value & _
ThisWorkbook.Sheets("Master").Range("E7").Value & " " &
ThisWorkbook.Sheets("Report").Range("B63").Value & _
ThisWorkbook.Sheets("Master").Range("E8").Value & " " &
ThisWorkbook.Sheets("Report").Range("B64").Value & _
ThisWorkbook.Sheets("Master").Range("E9").Value & _
ThisWorkbook.Sheets("Master").Range("E10").Value & _
ThisWorkbook.Sheets("Master").Range("E11").Value & " " &
ThisWorkbook.Sheets("Report").Range("B33").Value & _
ThisWorkbook.Sheets("Master").Range("E12").Value & " " &
ThisWorkbook.Sheets("Report").Range("B34").Value & _
ThisWorkbook.Sheets("Master").Range("E13").Value & " " &
ThisWorkbook.Sheets("Report").Range("B35").Value & _
ThisWorkbook.Sheets("Master").Range("E14").Value & _
ThisWorkbook.Sheets("Master").Range("E15").Value & _
ThisWorkbook.Sheets("Master").Range("E16").Value & " " &
ThisWorkbook.Sheets("Report").Range("B56").Value & _
ThisWorkbook.Sheets("Master").Range("E17").Value & " " &
ThisWorkbook.Sheets("Report").Range("B57").Value & _
ThisWorkbook.Sheets("Master").Range("E18").Value & " " &
ThisWorkbook.Sheets("Report").Range("B58").Value & _
ThisWorkbook.Sheets("Master").Range("E19").Value & _
ThisWorkbook.Sheets("Master").Range("E20").Value & _
ThisWorkbook.Sheets("Master").Range("E21").Value & " " &
ThisWorkbook.Sheets("Report").Range("B49").Value & _
ThisWorkbook.Sheets("Master").Range("E22").Value & " " &
ThisWorkbook.Sheets("Report").Range("B50").Value & _
ThisWorkbook.Sheets("Master").Range("E23").Value & " " &
ThisWorkbook.Sheets("Report").Range("B51").Value & _
ThisWorkbook.Sheets("Master").Range("E24").Value & " " &
ThisWorkbook.Sheets("Report").Range("B52").Value
With Destwb
On Error Resume Next
With OutMail
.To = ThisWorkbook.Sheets("Master").Range("B1").Value
.CC = ""
.BCC = ""
.Subject = ThisWorkbook.Sheets("Report").Range("B2").Value
.Body = strbody
.ReadReceiptRequested = False
.Importance = 1
.Send
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%S"
End With
On Error GoTo 0
.Close SaveChanges:=False
End With
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub