0

I would like to create this table and loop creating rows for an email template using vba:

<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:"Times New Roman",serif;color:black'>&nbsp;<o:p></o:p></span></b></p></td></tr></table>

I tried:

FullString = "<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>FirstName<o:p></o:p></span></b></p></td></tr></table>"

ReplaceWith = "<td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>James<o:p></o:p></span></b></p></td></tr><td width=254 nowrap style='width:190.75pt;border:none;border-bottom:solid white 1.0pt;background:#BDD7EE;padding:0in 5.4pt 0in 5.4pt;height:16.5pt'><p class=MsoNormal align=center style='text-align:center'><b><span style='font-family:""&""Times New Roman""&"",serif;color:black'>FirstNameReplace<o:p></o:p></span></b></p></td></tr></table>"

oTemplate.HTMLBody = Replace(oTemplate.HTMLBody, FullString, ReplaceWith )

Nothing was replaced.

Dai
  • 141,631
  • 28
  • 261
  • 374
John Hang
  • 125
  • 7

1 Answers1

0

I thnk you can follow this formula to replace

.HTMLBody = Replace(.HTMLBody, "#recipient#", "Some other value")

more 1

more 2

betrice mpalanzi
  • 1,436
  • 12
  • 16
  • The reason I do the way I am doing is because I'm going to loop to recreate the keywords to be replaced if customer are more than one. The table contains a style that I need so the row will be recreate. – John Hang Aug 13 '17 at 21:05
  • hii is this help https://stackoverflow.com/questions/41886251/dynamically-create-html-table-rows-with-vba – betrice mpalanzi Aug 13 '17 at 21:23
  • not really, because I have my own email template that I'm going to use. I just need to know how I'm going to add additional rows. – John Hang Aug 13 '17 at 22:06