Help with ConvertToTable

  • Thread starter Thierry Marneffe
  • Start date
T

Thierry Marneffe

Hello

Using Visual C++

I'm using ConvertToTable to build a Word Table from a string where separator
is the tab... Working fine ..

Ex: Data1\tData2\tData3\t ...
gives one table with several rows and 3 colums
| Data1 | Data2 | Data3 |
| Data1 | Data2 | Data 3|

What I'd like to do is adding several lines in some cells as this

| Data1 | Data2 | Data3 |
Data2'
Data2''
| Data1 | Data2 | Data 3 |

I tried to do it by inserting \n in the code of the cell as this

Data1\tData2\nData2'\nData2''\tData3\t ... but Word interprets \n as a new
row, not a new line on the cell of the current row ..

Also, how can I force Word to make a fit according to the Header size ...

Thanks for your help

Thierry
 
H

Helmut Weber

Hi Thierry,

one way would be to use a placeholder for a line break,
like # and replace # with a linebreak afterwards.

Another rather odd way would be, to use chr(7) as linebreak.
The result is astonishingly enough, a cell containing
more than one end-of-cell mark. However, if you select the
cell and exclude the last (!) end of cell mark,
Selection.Text = Replace(Selection.Text, Chr(7), Chr(11))
You get what you want.

Of course, you have to loop through all cells,
or remember before, what cells contain this chr(7).
Also, how can I force Word to make a fit according to the Header size ...

Not quite sure, what you mean. You might want to use something like
InitialColumnWidth:=CentimetersToPoints(2)
plus
AllowAutoFit = False

HTH

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top