Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Walter Briscoe Walter Briscoe is offline
external usenet poster
 
Posts: 42
Default Navigating logical table rows

I use Word 2003 SP1 on Windows XP Professional SP2.
I am very new to VBA programming and usually produce code by recording a
macro and seeing what is done.

I have a document which consists of one table.
The table consists of "logical" rows.

A "logical" row is either a single physical row as in:
R1C1 R1C2 R1C3 R1C4 ...
or a multiple physical row
R1C1 R1C2 R1C3 R1C4 ...
R2C3 R2C4 ...
R3C3 R3C4 ...

I want to pad some logical rows identified by find.execute as in
R1C1 R1C2 find R1C4 ...
or
R1C1 R1C2 R1C3 R1C4 ...
R2C3 find ...
R3C3 R3C4 ...

with bottom padding as in:
R1C1 R1C2 find R1C4 ...
botm botm botm botm ...
or

R1C1 R1C2 R1C3 R1C4 ...
R2C3 find ...
R3C3 R3C4 ...
botm botm ...

The last row happens to be of the form
R1C1 R1C2 find R1C4 ...
and a found cell can be anywhere in a logical row.

I have struggled without success to identify the relevant physical rows.

Incidentally, I was surprised to find that, at the last cell on the last
row, Selection.MoveRight Unit:=wdCell (which the Tab key maps to) causes
a new empty row to be appended.) I do not find this described in the
help for MoveRight.

I also have not found a key or a function which causes a Selection to be
closed as a mouse click outside the selection would do.

If this is not an appropriate group, I apologise for not kibitzing for
long enough and would value suggestions of a better one.

I would also value pointers to any good tutorials on table navigation.
--
Walter Briscoe
  #2   Report Post  
Posted to microsoft.public.word.tables
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default Navigating logical table rows

To: Walter Briscoe,

Sub NavigatingRowsAndColumns()
Dim oTable As Table
Dim row As Long
Dim col As Long
Dim s As String

Set oTable = ActiveDocument.Tables(1)
For row = 1 To oTable.rows.count
For col = 1 To oTable.rows(row).Cells.count
s = oTable.rows(row).Cells(col).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next col
Next row
End Sub

The above will not work if cells in the table have been split or merged.
Also, there are other ways to do this, but the above macro illustrates a
simple method.

As for the rest of your message, I couldn't quite figure out what you
wanted. Perhaps you could try again to state what you're wanting. (Also, you
realize that you are in a Word newgroup and not an Excel newsgroup, yes?)

Steven Craig Miller

"Walter Briscoe" wrote:

I use Word 2003 SP1 on Windows XP Professional SP2.
I am very new to VBA programming and usually produce code by recording a
macro and seeing what is done.

I have a document which consists of one table.
The table consists of "logical" rows.

A "logical" row is either a single physical row as in:
R1C1 R1C2 R1C3 R1C4 ...
or a multiple physical row
R1C1 R1C2 R1C3 R1C4 ...
R2C3 R2C4 ...
R3C3 R3C4 ...

I want to pad some logical rows identified by find.execute as in
R1C1 R1C2 find R1C4 ...
or
R1C1 R1C2 R1C3 R1C4 ...
R2C3 find ...
R3C3 R3C4 ...

with bottom padding as in:
R1C1 R1C2 find R1C4 ...
botm botm botm botm ...
or

R1C1 R1C2 R1C3 R1C4 ...
R2C3 find ...
R3C3 R3C4 ...
botm botm ...

The last row happens to be of the form
R1C1 R1C2 find R1C4 ...
and a found cell can be anywhere in a logical row.

I have struggled without success to identify the relevant physical rows.

Incidentally, I was surprised to find that, at the last cell on the last
row, Selection.MoveRight Unit:=wdCell (which the Tab key maps to) causes
a new empty row to be appended.) I do not find this described in the
help for MoveRight.

I also have not found a key or a function which causes a Selection to be
closed as a mouse click outside the selection would do.

If this is not an appropriate group, I apologise for not kibitzing for
long enough and would value suggestions of a better one.

I would also value pointers to any good tutorials on table navigation.
--
Walter Briscoe

  #3   Report Post  
Posted to microsoft.public.word.tables
Walter Briscoe Walter Briscoe is offline
external usenet poster
 
Posts: 42
Default Navigating logical table rows

In message of Thu,
21 Aug 2008 06:34:00 in microsoft.public.word.tables, StevenM
writes

Thanks, Steven for a really prompt reply.

To: Walter Briscoe,

Sub NavigatingRowsAndColumns()
Dim oTable As Table
Dim row As Long
Dim col As Long
Dim s As String

Set oTable = ActiveDocument.Tables(1)
For row = 1 To oTable.rows.count
For col = 1 To oTable.rows(row).Cells.count


That line generates "Cannot access individual rows in this collection
because the table has vertically merged cells".
I got a similar failure when I nested for each oTable, for each oRow,
and for each oCol

s = oTable.rows(row).Cells(col).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next col
Next row
End Sub

The above will not work if cells in the table have been split or merged.
Also, there are other ways to do this, but the above macro illustrates a
simple method.


I guess I need a less simple method.


As for the rest of your message, I couldn't quite figure out what you
wanted. Perhaps you could try again to state what you're wanting. (Also, you
realize that you are in a Word newgroup and not an Excel newsgroup, yes?)


I view this as 2 rows:
R1aC1 R1aC2 R1aC3 R1aC4
R1bC3
R2C1 R2C2 R2C3 R2C4

Word views it as
R1C1 R1C2 R1C3 R1C4
R2C1
R3C1 R3C2 R3C3 R3C4

I do understand I am dealing with Word tables. I reckon I have
vertically split cells which Word views as vertically merged cells. The
difference is on how you get there.

Steven Craig Miller


[snip]
--
Walter Briscoe
  #4   Report Post  
Posted to microsoft.public.word.tables
StevenM[_2_] StevenM[_2_] is offline
external usenet poster
 
Posts: 169
Default Navigating logical table rows

To: Walter Brisoe,

As I understand it, one has only three possibilities.

The first example merely repeats what I sent before.

Sub NavigatingTableViaRows()
Dim oTable As Table
Dim row As Long
Dim col As Long
Dim s As String

Set oTable = ActiveDocument.Tables(1)
For row = 1 To oTable.rows.count
For col = 1 To oTable.rows(row).Cells.count
s = oTable.rows(row).Cells(col).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next col
Next row
End Sub

Sub NavigatingTableViaColumns()
Dim oTable As Table
Dim row As Long
Dim col As Long
Dim s As String
Set oTable = ActiveDocument.Tables(1)
For col = 1 To oTable.Columns.count
For row = 1 To oTable.Columns(col).Cells.count
s = oTable.Columns(col).Cells(row).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next row
Next col
End Sub

Sub NavigatingTableViaCells()
Dim oTable As Table
Dim cell As Long
Dim s As String
Set oTable = ActiveDocument.Tables(1)
For cell = 1 To oTable.Range.Cells.count
s = oTable.Range.Cells(cell).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next cell
End Sub

Steven Craig Miller

"Walter Briscoe" wrote:

In message of Thu,
21 Aug 2008 06:34:00 in microsoft.public.word.tables, StevenM
writes

Thanks, Steven for a really prompt reply.

To: Walter Briscoe,

Sub NavigatingRowsAndColumns()
Dim oTable As Table
Dim row As Long
Dim col As Long
Dim s As String

Set oTable = ActiveDocument.Tables(1)
For row = 1 To oTable.rows.count
For col = 1 To oTable.rows(row).Cells.count


That line generates "Cannot access individual rows in this collection
because the table has vertically merged cells".
I got a similar failure when I nested for each oTable, for each oRow,
and for each oCol

s = oTable.rows(row).Cells(col).Range.Text
s = Left(s, Len(s) - 2)
MsgBox s
Next col
Next row
End Sub

The above will not work if cells in the table have been split or merged.
Also, there are other ways to do this, but the above macro illustrates a
simple method.


I guess I need a less simple method.


As for the rest of your message, I couldn't quite figure out what you
wanted. Perhaps you could try again to state what you're wanting. (Also, you
realize that you are in a Word newgroup and not an Excel newsgroup, yes?)


I view this as 2 rows:
R1aC1 R1aC2 R1aC3 R1aC4
R1bC3
R2C1 R2C2 R2C3 R2C4

Word views it as
R1C1 R1C2 R1C3 R1C4
R2C1
R3C1 R3C2 R3C3 R3C4

I do understand I am dealing with Word tables. I reckon I have
vertically split cells which Word views as vertically merged cells. The
difference is on how you get there.

Steven Craig Miller


[snip]
--
Walter Briscoe

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logical criteria in query option Ramesh Mailmerge 2 March 11th 07 09:47 AM
How do I repeat table header rows when the table has section break jmiller8 Tables 5 September 5th 06 04:51 PM
repeat header rows of a table when the table has section breaks jmiller8 Tables 1 August 31st 06 02:24 PM
adjustment of space of the tabulations and far from being logical DM Microsoft Word Help 1 May 28th 06 02:11 PM
how do you add graphics to a label? the logical is not working Doug Mailmerge 1 October 6th 05 07:37 PM


All times are GMT +1. The time now is 12:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"