2017-08-13 47 views
0

HTML表我想创建该表和循环创造了行使用VBA的电子邮件模板:创建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> 

我想:

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) 

没有被换下。

+0

插入表格对象插入到邮件正文 – jsotola

回答

0

我thnk你可以按照这个公式来代替

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

more 1

more 2

+0

我之所以这样做,我做的方法是因为如果客户不止一个,我将循环重新创建要替换的关键字。该表包含我需要的样式,因此该行将被重新创建。 –

+0

hii是这个帮助https://stackoverflow.com/questions/41886251/dynamically-create-html-table-rows-with-vba –

+0

不是真的,因为我有我自己的电子邮件模板,我打算使用。我只需要知道我将如何添加额外的行。 –