I have a macro that generates an Outlook email. One of the requirements is to add table to the email. The other requirement is to have the 1st part of the email in French and then the 2nd part of the email in English. So I’m replicating the table with different headings. I’ve got it working except that the table borders are different and I would like to make them consistent.
I’m self taught from what I can learn from sites like this but I cannot figure out how to make the borders the same on both tables.. Any help or suggestions would be greatly appreciated. Thanks in advance….
Here is the code I’m using:
TmpStr = ""
TmpStr = Trim(Workbooks(DataBook).Worksheets(1).Cells(r, 6))
strBeforeRows1 = ""
strRows1 = ""
strBeforeRows1 = "<head><style>table, th, td {border: 1px solid gray; border-collapse:" & _
"collapse;}</style></head><body>" & _
"<table style=""width:60%""><tr>" & _
"<th bgcolor=""#11ed69"">Field 1</th>" & _
"<th bgcolor=""#11ed69"">Field 2</th>" & _
"<th bgcolor=""#11ed69"">Field 3</th>" & _
"<th bgcolor=""#11ed69"">Field 4</th>" & _
"<th bgcolor=""#11ed69"">Field 5</th>" & _
"<th bgcolor=""#11ed69"">Field 6</th>"
Do While Trim(Workbooks(DataBook).Worksheets(1).Cells(r, 6)) = TmpStr
DoEvents
// Execute code to fill variables for the tables
strRows1 = strRows1 & "<tr>"
strRows1 = strRows1 & "<td ""col width=15%"" ""col align=center"">" & MyVIN & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=left"">" & MyPlate & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & MyYear & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & MyMake & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & MyModel & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & MySeries & "</td>"
strRows1 = strRows1 & "</tr>"
r = r + 1
Loop
strRows1 = strRows1 & "<tr>"
strRows1 = strRows1 & "<td ""col width=15%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows1 = strRows1 & "</tr>"
strAfterRows1 = "</table></body>"
StrAll1 = strBeforeRows1 & strRows1 & strAfterRows1
StrBody = ""
StrBody2 = ""
StrBody3 = ""
StrBody4 = ""
StrBody5 = ""
StrBody6 = ""
StrBody7 = ""
// Execute code to fill more variables
StrBody = "<font size=""3"" face=""Calibri"">" & "verbiage"
StrBody2 = "<font size=""3"" face=""Calibri"">" & "signature
StrBody3 = "<font size=""3"" face=""Calibri"">" & StrBody & StrAll1 & StrBody2
StrBody4 = "<font size=""3"" face=""Calibri"">" & "English verbiage"
strBeforeRows2 = ""
strBeforeRows2 = "<head><style>table, th, td {border: 1px solid gray; border-collapse:" & _
"collapse;}</style></head><body>" & _
"<table style=""width:60%""><tr>" & _
"<th bgcolor=""#11ed69"">Field 1</th>" & _
"<th bgcolor=""#11ed69"">Field 2</th>" & _
"<th bgcolor=""#11ed69"">Field 3</th>" & _
"<th bgcolor=""#11ed69"">Field 4</th>" & _
"<th bgcolor=""#11ed69"">Field 5</th>" & _
"<th bgcolor=""#11ed69"">Field 6</th>"
strRows2 = strRows2 & "<td ""col width=15%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "<td ""col width=10%"" ""col align=center"">" & " " & "</td>"
strRows2 = strRows2 & "</tr>"
strAfterRows2 = "</table></body>"
StrAll2 = ""
StrAll2 = strBeforeRows2 & strRows1 & strAfterRows1
StrBody5 = "<font size=""3"" face=""Calibri"">" & _ "english signature"
StrBody6 = "<font size=""3"" face=""Calibri"">" & StrBody4 & StrAll2 & StrBody5
StrBody7 = "<font size=""3"" face=""Calibri"">" & StrBody3 & StrBody6
// code to generate email
You need to sign in to view this answers
Leave feedback about this