Here's another challenging problem to solve.
I'm generating a word doc with a macro in excel that takes a list of cells and builds a table on a new word doc. If a cell is numeric, it puts it in column 2, but if it's not numeric it puts it in column 1, like this
results in:
<table col = 2 row = 3>
<tr><td>1. Do This</td><td></td></tr>
<tr><td>2. Do That</td><td>123<br>321</td></tr>
<tr><td>3. Do This</td><td>456</td></tr>
<tr><td>4. Do This</td><td>654</td></tr>
</table>
What I need to do is format just the "321" in the second row, let's say make it red and bold.
My objects are as follows:
When I'm writing to a particular cell, I can append to the cell contents by using
But then the string takes the same formatting as the rest of the cell. Is there a way to append a formatted object to a cell? If so, what kind of object and how do I format it?
I hope that's clear! It's not an easy one to word...
Thanks all!
-Mike
I'm generating a word doc with a macro in excel that takes a list of cells and builds a table on a new word doc. If a cell is numeric, it puts it in column 2, but if it's not numeric it puts it in column 1, like this
Code:
Do This
Do That
123
321
Do this
456
Do that
654
results in:
<table col = 2 row = 3>
<tr><td>1. Do This</td><td></td></tr>
<tr><td>2. Do That</td><td>123<br>321</td></tr>
<tr><td>3. Do This</td><td>456</td></tr>
<tr><td>4. Do This</td><td>654</td></tr>
</table>
What I need to do is format just the "321" in the second row, let's say make it red and bold.
My objects are as follows:
Code:
Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Add
objWord.Visible = True
Set objSelection = objWord.Selection
Set objRange = objDoc.Range
objDoc.Tables.Add objRange, 1, 4
Set objTable = objDoc.Tables(1)
When I'm writing to a particular cell, I can append to the cell contents by using
Code:
objTable.cell(1,2).Range.Text = objTable.cell(1,2).Range.Text + theString
But then the string takes the same formatting as the rest of the cell. Is there a way to append a formatted object to a cell? If so, what kind of object and how do I format it?
I hope that's clear! It's not an easy one to word...
Thanks all!
-Mike