Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
Hi gang,
I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
Use:
Dim i As Long Dim myTable As Table Dim myrange As Range With ActiveDocument For i = 1 To .Tables.Count Set myTable = .Tables(i) With myTable Set myrange = .Range Select Case myrange.Information(wdActiveEndPageNumber) Case Is 99 201 .AutoFitBehavior wdAutoFitFixed .Columns(1).Width = CentimetersToPoints(10) .Columns(2).Width = CentimetersToPoints(2) '.Columns(3).Width = CentimetersToPoints(#) '.Columns(4).Width = CentimetersToPoints(#) End Select End With Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi gang, I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
#3
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
Hi Doug,
Thanks for your reply! There's only one thing wrong: I get a: Run-time error '5941': The requested member of the collection does not exist. at the line: .Columns(3).Width = CentimetersToPoints(6.37) (I did take out the apostrophe). Any ideas? Cheers. "Doug Robbins - Word MVP" wrote: Use: Dim i As Long Dim myTable As Table Dim myrange As Range With ActiveDocument For i = 1 To .Tables.Count Set myTable = .Tables(i) With myTable Set myrange = .Range Select Case myrange.Information(wdActiveEndPageNumber) Case Is 99 201 .AutoFitBehavior wdAutoFitFixed .Columns(1).Width = CentimetersToPoints(10) .Columns(2).Width = CentimetersToPoints(2) '.Columns(3).Width = CentimetersToPoints(#) '.Columns(4).Width = CentimetersToPoints(#) End Select End With Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi gang, I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
#4
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
How many columns are there in your table?
-- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi Doug, Thanks for your reply! There's only one thing wrong: I get a: Run-time error '5941': The requested member of the collection does not exist. at the line: .Columns(3).Width = CentimetersToPoints(6.37) (I did take out the apostrophe). Any ideas? Cheers. "Doug Robbins - Word MVP" wrote: Use: Dim i As Long Dim myTable As Table Dim myrange As Range With ActiveDocument For i = 1 To .Tables.Count Set myTable = .Tables(i) With myTable Set myrange = .Range Select Case myrange.Information(wdActiveEndPageNumber) Case Is 99 201 .AutoFitBehavior wdAutoFitFixed .Columns(1).Width = CentimetersToPoints(10) .Columns(2).Width = CentimetersToPoints(2) '.Columns(3).Width = CentimetersToPoints(#) '.Columns(4).Width = CentimetersToPoints(#) End Select End With Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi gang, I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
#5
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
4: the four columns are split up into groups of 2, so columns 1 & 4 are the
same size, and columns 2 & 3 are the same size too. Cheers "Doug Robbins - Word MVP" wrote: How many columns are there in your table? -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi Doug, Thanks for your reply! There's only one thing wrong: I get a: Run-time error '5941': The requested member of the collection does not exist. at the line: .Columns(3).Width = CentimetersToPoints(6.37) (I did take out the apostrophe). Any ideas? Cheers. "Doug Robbins - Word MVP" wrote: Use: Dim i As Long Dim myTable As Table Dim myrange As Range With ActiveDocument For i = 1 To .Tables.Count Set myTable = .Tables(i) With myTable Set myrange = .Range Select Case myrange.Information(wdActiveEndPageNumber) Case Is 99 201 .AutoFitBehavior wdAutoFitFixed .Columns(1).Width = CentimetersToPoints(10) .Columns(2).Width = CentimetersToPoints(2) '.Columns(3).Width = CentimetersToPoints(#) '.Columns(4).Width = CentimetersToPoints(#) End Select End With Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi gang, I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
#6
Posted to microsoft.public.word.tables
|
|||
|
|||
Word Macro to Format Tables
So you want to make the total width of the table 60cm. That would exceed
the maximum page width that Word can accommodate which is abot 55.88cm. There is nothing wrong with the macro as long an you do not have it contain values that would make the table wider than the maximum page width. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... 4: the four columns are split up into groups of 2, so columns 1 & 4 are the same size, and columns 2 & 3 are the same size too. Cheers "Doug Robbins - Word MVP" wrote: How many columns are there in your table? -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi Doug, Thanks for your reply! There's only one thing wrong: I get a: Run-time error '5941': The requested member of the collection does not exist. at the line: .Columns(3).Width = CentimetersToPoints(6.37) (I did take out the apostrophe). Any ideas? Cheers. "Doug Robbins - Word MVP" wrote: Use: Dim i As Long Dim myTable As Table Dim myrange As Range With ActiveDocument For i = 1 To .Tables.Count Set myTable = .Tables(i) With myTable Set myrange = .Range Select Case myrange.Information(wdActiveEndPageNumber) Case Is 99 201 .AutoFitBehavior wdAutoFitFixed .Columns(1).Width = CentimetersToPoints(10) .Columns(2).Width = CentimetersToPoints(2) '.Columns(3).Width = CentimetersToPoints(#) '.Columns(4).Width = CentimetersToPoints(#) End Select End With Next i End With -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Rage" wrote in message ... Hi gang, I have a 300-odd MS Word Document (Word Version 2003) with quite a lot of tables, and I was wondering - can someone possibly provide me with a macro which will take all the tables in a range (e.g.) pages 100 - 200, and set the width of each column to a specific value (e.g.) column 1 = 10 cm, column 2 = 20 cm etc.? All the tables in the range needed have 4 columns, but each column needs to be a different value to the others. Thanks in advance, Rage. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Button Macro for Caclulating in Word Tables | Tables | |||
Creating a macro for Tables in Word 97 | New Users | |||
For the archive, code to format (styles and column widths) tables and nested tables | Tables | |||
Macro for word tables to excel | Tables | |||
Macro to replace styles used in tables (Word 2000/Windows) | Tables |