sand60
06-01-2016, 09:50 AM
Hi all, :)
I am trying to come up with a way to convert html to a word table.
Sometimes I get pasted text that has html tables within and i need to find a way to see if i can extract that data into a table?
That is put it into a table format.
I found this excellent thread - but unfortunately I couldn't get it to work.
http://stackoverflow.com/questions/29483422/parsing-html-to-recreate-tables-in-a-word-document-using-vba
I have a sketch of whats involved:
1 Header - the th cells - need to be identified
Count how many <tr> there are - each <tr> is a row
Insert and space out the code
<th>1</th><th>Texas </th> <th>519</th><th>1</th></tr></thead><tbody>
<tr><td>2</td> <td>Illinois </td>
<td>502</td> <td>2</td></tr>
<tr><td>3</td><td>Stanford</td><td>486</td><td>5</td></tr>
<tr><td>4</td><td>Georgia</td><td>463</td><td>3</td></tr>
<tr><td>5</td><td>Oklahoma State</td><td>416</td><td>6</td></tr>
</tbody></table>
I tried recording a macro - that was no use.
I inserted tabs after the </td> to space it out, then convert, still no luck.
How can I use vba to convert this html table code to a Word Document table?
If any one has any tips - I would be grateful.
Also - this is a challenging task as I have been trying to get this to work for a while, my newbie skills really letting me down
thank you for your time
sand
I am trying to come up with a way to convert html to a word table.
Sometimes I get pasted text that has html tables within and i need to find a way to see if i can extract that data into a table?
That is put it into a table format.
I found this excellent thread - but unfortunately I couldn't get it to work.
http://stackoverflow.com/questions/29483422/parsing-html-to-recreate-tables-in-a-word-document-using-vba
I have a sketch of whats involved:
1 Header - the th cells - need to be identified
Count how many <tr> there are - each <tr> is a row
Insert and space out the code
<th>1</th><th>Texas </th> <th>519</th><th>1</th></tr></thead><tbody>
<tr><td>2</td> <td>Illinois </td>
<td>502</td> <td>2</td></tr>
<tr><td>3</td><td>Stanford</td><td>486</td><td>5</td></tr>
<tr><td>4</td><td>Georgia</td><td>463</td><td>3</td></tr>
<tr><td>5</td><td>Oklahoma State</td><td>416</td><td>6</td></tr>
</tbody></table>
I tried recording a macro - that was no use.
I inserted tabs after the </td> to space it out, then convert, still no luck.
How can I use vba to convert this html table code to a Word Document table?
If any one has any tips - I would be grateful.
Also - this is a challenging task as I have been trying to get this to work for a while, my newbie skills really letting me down
thank you for your time
sand