Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
MichaelB
 
Posts: n/a
Default How can I implement a specific text style within a table?

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   Report Post  
Posted to microsoft.public.word.tables
Cindy M -WordMVP-
 
Posts: n/a
Default How can I implement a specific text style within a table?

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

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating dynamic cross reference links in a Word document torajudo Microsoft Word Help 5 April 27th 23 08:57 PM
Use of Character styles Sverre Medalen Microsoft Word Help 8 August 25th 05 01:54 PM
How do you end or "turn off" a character style while entering text Larry Root Microsoft Word Help 3 April 25th 05 03:29 PM
How to Avoid Word 2003 Table Style Problems Judy Haynes Tables 0 March 23rd 05 06:41 PM
Outline Renee Hendershott Page Layout 2 December 25th 04 02:49 PM


All times are GMT +1. The time now is 02:45 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"