Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
aaargh!! please help. I have various tables with varying column thicknesses
but the same number of columns. I need to copy rows between tables. The columns never line up and I am wasting so much time with trying to get them aligned (dragging columns with ALT key down and/or playing with column widths, etc). Is there a way of linking the position of the columns in one row with the row above? Any tricks would be appreciated. |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
Hi Robin,
I don't see a way, but using a bit of programming, like: Sub SameWidth() ' set all cells in row to width 0.5 inches Dim oCll As Cell Dim oRow As Row Set oRow = selection.Rows(1) For Each oCll In oRow.Cells oCll.Width = InchesToPoints(0.5) Next MsgBox selection.Tables(1).Uniform End Sub As I don't know if you have any idea of VBA, this is a very basic, very limited sample. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
Super, thanks. This has just propelled me into the powerful world of Word
macros. "Helmut Weber" wrote: Hi Robin, I don't see a way, but using a bit of programming, like: Sub SameWidth() ' set all cells in row to width 0.5 inches Dim oCll As Cell Dim oRow As Row Set oRow = selection.Rows(1) For Each oCll In oRow.Cells oCll.Width = InchesToPoints(0.5) Next MsgBox selection.Tables(1).Uniform End Sub As I don't know if you have any idea of VBA, this is a very basic, very limited sample. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
One more question: sometimes the "uniform" field comes back false, even
though all the columns have been set to be the same width. Any way of forcing them to be uniform? "Robin" wrote: Super, thanks. This has just propelled me into the powerful world of Word macros. "Helmut Weber" wrote: Hi Robin, I don't see a way, but using a bit of programming, like: Sub SameWidth() ' set all cells in row to width 0.5 inches Dim oCll As Cell Dim oRow As Row Set oRow = selection.Rows(1) For Each oCll In oRow.Cells oCll.Width = InchesToPoints(0.5) Next MsgBox selection.Tables(1).Uniform End Sub As I don't know if you have any idea of VBA, this is a very basic, very limited sample. -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de" |
#5
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
Hi Robin,
aaargh!! Another bug? I very much think so. First I messed a 5 times 5 table up, like this: Sub Test9807() Dim oCll As Cell Dim oTbl As Table Dim x As Single Randomize Set oTbl = ActiveDocument.Tables(1) For Each oCll In oTbl.Range.Cells oCll.Select x = oCll.Width x = x + Int((12 * Rnd) + 1) oCll.Width = x Next End Sub Then I tried to make it uniform, like this: Sub Test9808() Dim oCll As Cell Dim oTbl As Table Set oTbl = ActiveDocument.Tables(1) For Each oCll In oTbl.Range.Cells oCll.Width = 30 Next MsgBox oTbl.Uniform ' ok End Sub But I had no chance to get it to work with larger tables, like 10 rows and 10 columns. The more I tried, the less successful I was. Maybe someone else knows better... -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA "red.sys" & chr(64) & "t-online.de" Word 2002, Windows 2000 (german versions) |
#6
Posted to microsoft.public.word.tables
|
|||
|
|||
margins of tables
Hi Robin,
slighty better than looping through all cells, which goes from left to right, worked this alternative approach: Sub Test9809() Dim oCll As Cell Dim oTbl As Table Dim lRow As Long Dim lClm As Long Set oTbl = ActiveDocument.Tables(1) For lClm = 1 To oTbl.Columns.Count For lRow = 1 To oTbl.Rows.Count oTbl.Cell(lRow, lClm).Select Selection.Cells(1).Width = 30 Next Next MsgBox oTbl.Uniform End Sub This worked at first run for the rows 1 til 9 in a 10 times 10 table. The second run then managed to set the width of the cells in row 10, too. HTH -- Greetings from Bavaria, Germany Helmut Weber, MVP WordVBA "red.sys" & chr(64) & "t-online.de" Word 2002, Windows 2000 (german versions) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto-numbering bug in tables - Word 2003 | Tables | |||
How do i keep tables imported from excel inside the the margins? | Microsoft Word Help | |||
Changing format of multiple pre-created tables | Microsoft Word Help | |||
Column margins in tables | Tables | |||
When joining tables, table sections shift left or right. | Tables |