table with merged cells

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

table with merged cells

Post by Robie »

Is it possible to get the cell position/value for a horizontally merged table? It is a fixed table that holds couple of company logos that change to six different versions depending on user selection.
The reason that row 1 has only two cells is that cell 2 or row 1 contains document titles (and these need to be wide).
29.png
I have a table of
Row 1: 2 cells
Row 2: 3 cells.

I actually, only need to access (1,1) and (2,3) but this seems to be impossible under VBA! :sad:

Thanks.
Robie
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78849
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: table with merged cells

Post by HansV »

I have no problem referring to

ActiveDocument.Tables(1).Cell(1, 1)

and to

ActiveDocument.Tables(1).Cell(2, 3)

in a table similar to yours. What problem do you run into?
Best wishes,
Hans

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: table with merged cells

Post by macropod »

If you want to be able to quickly find a cell's address (even if mergeing & splitting is is use), you can do so with the following macro:

Code: Select all

Sub CellAddress()
'This macro displays the address of a table cell on Word's status bar
If Selection.Information(wdWithInTable) = True Then
  If Selection.Cells(1).ColumnIndex > 26 Then
    StatusBar = "Cell Address: " & Chr(64 + Int(Selection.Cells(1).ColumnIndex / 26)) & _
    Chr(64 + (Selection.Cells(1).ColumnIndex Mod 26)) & Selection.Cells(1).RowIndex
  Else
    StatusBar = "Cell Address: " & Chr(64 + Selection.Cells(1).ColumnIndex) & _
    Selection.Cells(1).RowIndex
  End If
End If
End Sub
The address is reported on Word's status bar.
Paul Edstein
[Fmr MS MVP - Word]

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: table with merged cells

Post by Robie »

HansV wrote:I have no problem referring to

ActiveDocument.Tables(1).Cell(1, 1)

and to

ActiveDocument.Tables(1).Cell(2, 3)

in a table similar to yours. What problem do you run into?
Thanks. Not sure what it was but I recreated the whole page and it seems to be fine now.