Ich verwende VBA, um eine Tabelle in einer Outlook-E-Mail zu erstellen. Ich habe herausgefunden, wie man die Tabelle generiert, aber mein Problem ist, dass ich die Anzahl der Zeilen in der Tabelle dynamisch anpassen muss. Für einige E-Mails gibt es zwei Datenzeilen, für andere drei, usw.HTML-Tabellenzeilen dynamisch mit VBA erstellen
Im folgenden Code ist rowstocontact
ein Collection
. Ich weiß, dass ich die Collection
Schleife durchlaufen und eine Zeile für jedes Element in der Auflistung hinzufügen möchte, aber ich kann nicht herausfinden, wie Sie eine Schleife in dem HTML-Code einfügen, der die Tabelle erstellt.
Jede Hilfe wird sehr geschätzt !! Vielen Dank.
bodytext = "<head><style>table, th, td {border: 1px solid gray; border-collapse:" & _
"collapse;}</style></head><body>" & _
"<table style=""width:60%""><tr>" & _
"<th bgcolor=""#bdf0ff"">Reviewee</th>" & _
"<th bgcolor=""#bdf0ff"">Manager(s)</th>" & _
"<th bgcolor=""#bdf0ff"">Project code</th>" & _
"<th bgcolor=""#bdf0ff"">Requested</th>" & _
"<th bgcolor=""#bdf0ff"">Type</th>" & _
"<th bgcolor=""#bdf0ff"">Due</th></tr><tr>" & _
"<td ""col width=10%"">" & Range("D" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("L" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("M" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("AJ" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("V" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("AK" & rowtocontact(1)) & "</td>" & _
"<td ""col width=10%"">" & Range("AK" & rowtocontact(1)) & "</td>" & _
"</tr></Table></body>"
Robin Mackenzie - können Sie mit meiner Post helfen? https://stackoverflow.com/questions/47360932/create-html-table-with-excel-data-dynamic-rows – Jono