Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Hello,
I have the below macro which reformats tables for me when certain criteria is met. I need to implement a section into each condition that would set the text style to €śTable Paragraph 1€ť for all the text within the table. It would be ideal to do this without removing any BOLDED text that currently exists within the cells, but I know this may be impossible. My end result is to have all the text within my tables be formatted with the €śTable Paragraph 1€ť style although I do have several hundred cells where the first sentence is bolded. Maybe it is best to do this one at a time..? Any help would be greatly appreciated?? Thx Mike ' Macro to identify text within the first cell of a table and calculate the number ' of columns. Depending on criteria the macro will modify the tables accordingly. ' Note this macro works backwards starting from the end of the document processing ' toward the top. Sub ResizeTables() Dim oTbl As Table Dim iTbl As Integer Dim oCl As Cell Dim oRng As Range For iTbl = ActiveDocument.Tables.Count To 1 Step -1 Set oTbl = ActiveDocument.Tables(iTbl) Set oCl = oTbl.Cell(1, 1) Set oRng = oCl.Range oRng.MoveEnd Unit:=wdCharacter, Count:=-1 If oTbl.Columns.Count = 4 And oRng.Text = "Version" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowLeft ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(0.88) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(1.5) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(0.94) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(3#) End If If oTbl.Columns.Count = 4 And oRng.Text = "Name" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowLeft ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(1.31) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(1.5) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(2.56) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(0.95) End If If oTbl.Columns.Count = 4 And oRng.Text = "Document Name" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowLeft ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(1.31) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(1.5) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(2.56) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(0.95) End If If oTbl.Columns.Count = 4 And oRng.Text = "Requirement" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowRight ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(1#) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(0.69) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(0.63) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(3#) End If If oTbl.Columns.Count = 5 And oRng.Text = "Item" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowRight ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(0.44) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(0.69) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(0.63) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(1.65) ActiveDocument.Tables(iTbl).Columns(5).PreferredWi dth = InchesToPoints(1.65) End If If oTbl.Columns.Count = 5 And oRng.Text = "AC" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowRight ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(0.64) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(2.19) ActiveDocument.Tables(iTbl).Columns(3).PreferredWi dth = InchesToPoints(1.25) ActiveDocument.Tables(iTbl).Columns(4).PreferredWi dth = InchesToPoints(1.19) ActiveDocument.Tables(iTbl).Columns(5).PreferredWi dth = InchesToPoints(1.14) End If If oTbl.Columns.Count = 2 And oRng.Text = "Term" Then ActiveDocument.Tables(iTbl).Rows.Alignment = wdAlignRowLeft ' ActiveDocument.Tables(iTbl).Rows.DistanceLeft ActiveDocument.Tables(iTbl).AutoFitBehavior Behavior:=wdAutoFitFixed ActiveDocument.Tables(iTbl).Columns.PreferredWidth Type = wdPreferredWidthPoints ActiveDocument.Tables(iTbl).Columns(1).PreferredWi dth = InchesToPoints(1.56) ActiveDocument.Tables(iTbl).Columns(2).PreferredWi dth = InchesToPoints(3.75) End If Next iTbl End Sub |
#2
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Hi ?B?TWljaGFlbEI=?=,
I have the below macro which reformats tables for me when certain criteria is met. I need to implement a section into each condition that would set the text style to €śTable Paragraph 1€ť for all the text within the table. It would be ideal to do this without removing any BOLDED text that currently exists within the cells, but I know this may be impossible. My end result is to have all the text within my tables be formatted with the €śTable Paragraph 1€ť style although I do have several hundred cells where the first sentence is bolded. Maybe it is best to do this one at a time..? Well, in general terms, if you apply a paragraph style to bolded text, the bolding *might* be retained. It's a function of the percentage of text that's been formatted directly. In a quick test, this retained the bold applied to text in a table: oTble.Range.Style = "My style" Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Creating dynamic cross reference links in a Word document | Microsoft Word Help | |||
Use of Character styles | Microsoft Word Help | |||
How do you end or "turn off" a character style while entering text | Microsoft Word Help | |||
How to Avoid Word 2003 Table Style Problems | Tables | |||
Outline | Page Layout |