View Single Post
 
Old 08-22-2016, 02:04 AM
Grantsub Grantsub is offline Windows 10 Office 2013
Novice
 
Join Date: Aug 2016
Posts: 6
Grantsub is on a distinguished road
Default Word table auto text alignment vs cell height

Word table auto text alignment vs. cell height

I would like to use a VBA to clean up a word document table by aligning text in the each by a set of criteria eg height of cell = 6pt use macro one and if greater than 6 points use marco 2
I have been able to write the script separately but can think on away to join the two Marcos together so I physical don’t have to select the macro on each line or groups of line

At the moment I just selected Marco 1 or Macro2 depending on looking at each line this is very time consuming for 140 tables in a work doc

So the outcome I want is.
Run the Marco and it starts where the cursor is and continues through all the tables in the document highlighted with cursor the information on each line in the table is formatted and aligned determine to the height of the cell

Cell single height e.g. 6 point

Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.ColorIndex = wdBlack
Selection.Font.Size = 11
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Selection.Cells.VerticalAlignment = wdCellAlignVerticalTop
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.SelectCell


And if the cell is greater than 6 point < double height

Selection.SelectCell
Selection.Font.Name = "Arial"
Selection.Font.ColorIndex = wdBlack
Selection.Font.Size=11
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalTop
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.SelectCell

Can someone add the missing code for me so it auto formats the table and then I can just run on each word table or all table it will save hours

Thanks Grant
Reply With Quote