Convert ToTable

D

Derek

ok, I am building a string of data from an array and separating each cell
from the array with CHR(124) then ending the row with a "vbcr".

then I set the bookmark in the word document to the string of data, then
select the string of data and use the "ConvertToTable(chr(124))" and it works
beautifully!\

Now, the forst column of data contains a firstname lastname and full address
information(street, city, state, zip) and i would like to be able to format
this column so that the information appears as follows:

First Last name
Address Line 1
Address Line 2
City, State
Zip Code

When I build my data string I tried ending each field above with a chr(10)
or chr(13) to force it to the next line, but, the converttotable commande
sees these as separate lines when converting to a table, so I end up with 5
lines and the remaining columns in this line have 4 rows of empty data except
for the last line.

Does anyone know how to get around this and format this column as I did above?

Thanks !

Derek
 
P

Pesach Shelnitz

Hi Derek,

Word inserts paragraph breaks for both chr(10) and chr(13). What you need is
a line break, which can be inserted using chr(11).
 
D

Derek

Hi Pesach,

I tried using CHR(11) and creates the text as I need it but the
convertotable command creates the table with name, address, information all
on separate lines in the table. If you were to build a table and enter test
into a cell you can control when the line ends by hitting the "Enter key" and
this is what I am trying to simulate.

Thanks for you help!

Derek
 
M

Manfred F

Hi Derek,

this is a very common issue e.g. when working with csv formatted data.
A good solution is to mask the vbcr by some key that doesn't appear in the
data, create the table, and then unmask it again.

Regards,

Manfred
 
P

Pesach Shelnitz

Hi Derek,

If you want the line breaks created by chr(11), which are the same as line
breaks created by pressing Shift+Enter, to be changed to line breaks created
by pressing Enter after the table is created. You can do a search-and-replace
on the table with the search string ^l and the replacement string ^p. The
following code does this.

With Selection.Tables(1).Range.Find
.Text = "^l"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
 

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