Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Robin Robin is offline
external usenet poster
 
Posts: 112
Default 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   Report Post  
Posted to microsoft.public.word.tables
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default 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   Report Post  
Posted to microsoft.public.word.tables
Robin Robin is offline
external usenet poster
 
Posts: 112
Default 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   Report Post  
Posted to microsoft.public.word.tables
Robin Robin is offline
external usenet poster
 
Posts: 112
Default 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   Report Post  
Posted to microsoft.public.word.tables
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.word.tables
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 2
Default 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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-numbering bug in tables - Word 2003 mtnbutterfli Tables 2 June 22nd 06 01:10 PM
How do i keep tables imported from excel inside the the margins? nogibear Microsoft Word Help 2 May 17th 06 10:00 PM
Changing format of multiple pre-created tables Wendy Microsoft Word Help 2 September 14th 05 08:55 AM
Column margins in tables cmansbridge Tables 3 August 10th 05 12:26 PM
When joining tables, table sections shift left or right. JEB01 Tables 1 January 17th 05 07:57 PM


All times are GMT +1. The time now is 06:58 AM.

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"