![]() |
#1
|
||||
|
||||
![]()
I have large text file having repeating lines as follow
![]() I want to fit the text in the table like this ![]() I have following macro but the problem is it is for small text. I don't know how to loop. I optionally made repeatations but it throws error after say 20 repetition. my macro is as following: Sub PLR() ' ' PLR Macro ' ' Selection.Delete Unit:=wdCharacter, Count:=1 Selection.WholeStory Selection.Font.Name = "Palatino Linotype" Selection.Font.Size = 12 If Selection.PageSetup.Orientation = wdOrientPortrait Then Selection.PageSetup.Orientation = wdOrientLandscape Else Selection.PageSetup.Orientation = wdOrientLandscape End If Selection.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1, _ NumRows:=954, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) If .Style <> "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .ApplyStyleRowBands = True .ApplyStyleColumnBands = False End With Selection.InsertColumns Selection.InsertColumns Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Tables(1).Columns(2).SetWidth ColumnWidth:=206.7, RulerStyle:= _ wdAdjustNone Selection.Tables(1).AllowAutoFit = False Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=206, RulerStyle:= _ wdAdjustNone Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=418.5, RulerStyle:= _ wdAdjustNone Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.TypeText Text:="Abstract:" Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeText Text:="." Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdPasteDefault) Selection.EndKey Unit:=wdLine Selection.TypeBackspace Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Cells.Delete ShiftCells:=wdDeleteCellsEntireRow Selection.TypeBackspace Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.TypeText Text:="Abstract:" Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeText Text:="." Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdPasteDefault) Selection.EndKey Unit:=wdLine Selection.TypeBackspace Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Cells.Delete ShiftCells:=wdDeleteCellsEntireRow Selection.TypeBackspace Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeParagraph Selection.TypeText Text:="Abstract:" Selection.TypeParagraph Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.EndKey Unit:=wdLine Selection.TypeText Text:="." Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Cut Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.PasteAndFormat (wdPasteDefault) Selection.EndKey Unit:=wdLine Selection.TypeBackspace Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend Selection.Cells.Delete ShiftCells:=wdDeleteCellsEntireRow Selection.TypeBackspace |
Tags |
macro, table, word 2010 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extra lines in directroy when field is blank | redzan | Mail Merge | 5 | 05-23-2014 06:40 PM |
Re-Arrange Generated Data | flds | Excel | 4 | 06-29-2012 08:17 AM |
![]() |
JustK | Word | 2 | 11-15-2011 11:17 AM |
Large gap between lines. | Balliol | Word | 8 | 12-14-2010 04:59 PM |
Text Wrapping on Fixed Lines in a Form field/Table cell | okrmjr | Word Tables | 0 | 10-30-2009 08:52 AM |