Getting value in a table cell w/out CR

D

Dave

Hi,

Using Word 97 in Win 98.
I'm populating a two-dimensional array with values from a
table, kind of converting the table to an array.

Documents.Open FileName:="C:\doc.doc"
With ActiveDocument.Tables(1)
Dim rcount As Integer
rcount = .Rows.Count
Dim arrAddBook(0 To rcount, 2) As String
For i = 1 To rcount
arrAddBook(i, 0) = .Cell(i, 0).Range.Text
arrAddBook(i, 1) = .Cell(i, 1).Range.Text
arrAddBook(i, 2) = .Cell(i, 2).Range.Text
Next i
End With
ActiveDocument.Close wdDoNotSaveChanges

My array values contain unwanted CRs.
Is there a way to get the text of the cell without the CRs?

P.S. Is there a better way to accomplish my goal?

Thanks!
Dave
 
W

Word Heretic

G'day "Dave" <[email protected]>,

ignore the last two chars from the range using left$ and len.


Dave said:
Hi,

Using Word 97 in Win 98.
I'm populating a two-dimensional array with values from a
table, kind of converting the table to an array.

Documents.Open FileName:="C:\doc.doc"
With ActiveDocument.Tables(1)
Dim rcount As Integer
rcount = .Rows.Count
Dim arrAddBook(0 To rcount, 2) As String
For i = 1 To rcount
arrAddBook(i, 0) = .Cell(i, 0).Range.Text
arrAddBook(i, 1) = .Cell(i, 1).Range.Text
arrAddBook(i, 2) = .Cell(i, 2).Range.Text
Next i
End With
ActiveDocument.Close wdDoNotSaveChanges

My array values contain unwanted CRs.
Is there a way to get the text of the cell without the CRs?

P.S. Is there a better way to accomplish my goal?

Thanks!
Dave

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

Replies offlist may require payment.
 

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