If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
reading line from table cell into array
Hi,
I want to read a line from a table cell into an array. Just can not figure out how to read the lines into arrays. This is what I´ve got so far from http://mypage.bluewin.ch/reprobst/Wo...htm#Tabellen05 Sub WordTabelleNachEindimensionalenArray1() Dim x() As String Dim oTable As Table, Zelle As Cell If ActiveDocument.Tables.Count = 0 Then MsgBox "Das Dokument enthält keine Tabelle.", vbInformation Exit Sub End If Set oTable = ActiveDocument.Tables(1) ReDim x(1 To oTable.Range.Cells.Count) i = 0 'Oder auch -1, wenn der Array bei "0" beginnen soll For Each Zelle In oTable.Range.Cells i = i + 1 strText = Zelle.Range.Text x(i) = Left(strText, Len(strText) - 2) Next Zelle End Sub I can save the whole cell into the array, but not just one line. How should this be changed? Thanks in advance for every help Rob |
#2
|
|||
|
|||
reading line from table cell into array
Hi Rob,
I don't think this will hardly work without using the selection. Before I code something to work with a variety of lines, I'd like to know, whether you need always the same line, lets say line(2), how may lines there are in the cells, whether in each cell in the same number of lines, and whether the line you need can be the last line in a cell. Do lines wrap automatically or do You use linefeed or paragraph marks to enforce wrapping? Helmut Weber MVP Word VBA |
#3
|
|||
|
|||
reading line from table cell into array
Sorry, I don't fully understand your goal:
Do you have more than one line of text in a cell, and you want to seperate them? Or, do you want to read the contents of just one row of cells into an array, or ?? Regards Jay |
#4
|
|||
|
|||
reading line from table cell into array
"Helmut Weber" schrieb im Newsbeitrag
ups.com... Hi Rob, I don't think this will hardly work without using the selection. Before I code something to work with a variety of lines, I'd like to know, whether you need always the same line, lets say line(2), how may lines there are in the cells, whether in each cell in the same number of lines, and whether the line you need can be the last line in a cell. There is no regularity in the cells. For instance, you can have just three lines in one cell, but in another there are 6 lines, depending on the written data. Did I understand this right? Do lines wrap automatically or do You use linefeed or paragraph marks to enforce wrapping? There are linefeeds seperating the lines. Hope this helps us out Rob |
#5
|
|||
|
|||
reading line from table cell into array
"jay M" schrieb im Newsbeitrag
ups.com... Hi Jay Sorry, I don't fully understand your goal: Do you have more than one line of text in a cell, and you want to seperate them? That´s right. My final goal is to seperate the lines, wirte them into an array, and then export it into an excel sheet. That´s why I want to do this. Or, do you want to read the contents of just one row of cells into an array, or ?? Hm, can´t figure out what this means. In one cell I have some lines, and each of it should be written into an array to export them later into excel. Do you know what I mean right now? |
#6
|
|||
|
|||
reading line from table cell into array
Hi Robert
answered in ...public.word.vba.general Helmut |
#7
|
|||
|
|||
reading line from table cell into array
*** so you look at the contents of each cell, and:
for all cells in o_table if (contents of cell is what I want) then [split cell text at line breaks, put each line into seperate variable] else [check next cell] end if next cell **** right? |
#8
|
|||
|
|||
reading line from table cell into array
oops- I should have looked at the responses above- they didn't appear
in the word_tables forum where I found the question! I tend to forget the "split" function (not to confuse with any of the other 'split' operators) - the above is a nice example. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
copying cell names | Al | General Discussion | 3 | August 11th, 2005 03:01 PM |
Can I link 1 form to several tables? | Mico | Using Forms | 7 | July 6th, 2005 07:36 PM |
Pasting Word table cell with paragraph markers into single Excel c | Steve | General Discussion | 1 | June 16th, 2005 11:26 PM |
Table Wizard Does Not Set Relationship if Foreign Key and Primary Key Name Do Not Match Exactly in Case. | HDW | Database Design | 3 | October 16th, 2004 03:42 AM |
IF E3 & E10 = TRUE set this cell to "Yes", else set to "No" | Timothy L | Worksheet Functions | 5 | August 27th, 2004 02:28 AM |