![]() |
|
|
|
#1
|
|||
|
|||
|
Hi Guys, I have a macro that converts text to table format which works fine but I want to fine tune it a bit. Column 1 is set to 2.7 width (house style). I want to further format Column 1 to be left aligned (not justified) and indented to 1". I've tried all sorts within the macro but nothing seem to be working and I would be very grateful if someone could help me. Many thanks, Shelley
![]() Code:
Sub DPU_Tables()
Selection.WholeStory
Selection.Font.Name = "Arial"
Selection.Font.Size = 10
With Selection.ParagraphFormat
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 9
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceAtLeast
.LineSpacing = 15
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=8, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns(1).PreferredWidth = InchesToPoints(2.7)
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns(2).PreferredWidth = InchesToPoints(3.63)
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
End Sub
|
|
#2
|
||||
|
||||
|
How about
Code:
Sub DPU_Tables()
Dim oBorder As Border
Selection.WholeStory
Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
NumRows:=8, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
With .Range
.Font.Name = "Arial"
.Font.Size = 10
With .ParagraphFormat
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 9
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceAtLeast
.LineSpacing = 15
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End With
With .Columns(1)
.PreferredWidth = InchesToPoints(2.7)
.Select
With Selection.ParagraphFormat
.Alignment = wdAlignParagraphLeft
.LeftIndent = InchesToPoints(1)
End With
End With
With .Columns(2)
.Select
With Selection.ParagraphFormat
.Alignment = wdAlignParagraphJustify
End With
.PreferredWidth = InchesToPoints(3.63)
For Each oBorder In .Borders
oBorder.LineStyle = wdLineStyleNone
Next oBorder
End With
End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Thank you so much for replying Graham, the macro works fine except for the border around Column 1 - I can see the code is set to none so not sure why its got a border. Any ideas? Thanks, Shelley
Tables.JPG |
|
#4
|
||||
|
||||
|
copy the lines
Code:
For Each oBorder In .Borders
oBorder.LineStyle = wdLineStyleNone
Next oBorder
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#5
|
|||
|
|||
|
Graham, you are the best, thank you so much that worked perfectly, many thanks, Shelley
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to convert table to convert table into iCalendar file?
|
Weboh | Word VBA | 5 | 12-10-2016 03:07 PM |
Copying DNA from web and need to convert column date to ex: 11-15
|
JacMUr2 | Excel | 2 | 01-22-2016 03:36 AM |
| VBA to Format a Table Column in Excel | Sgt Rock | Excel | 0 | 02-14-2015 02:54 PM |
| How can I temporarily break a 3 column format in order to type a single column paragraph | William P | Word | 1 | 01-04-2015 06:40 PM |
1.image in a table 2.right click 3.menu click format 4.a format column appears
|
OldFatDog | Drawing and Graphics | 1 | 06-13-2014 11:19 PM |