![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
![]()
You might try something along the lines of the following macro:
Code:
Sub Demo() Application.ScreenUpdating = False Dim Rng As Range With ActiveDocument With .Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = ":[^s]{1,}" .Replacement.Text = ":^t" .Forward = True .Format = False .MatchWildcards = True .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll .Wrap = wdFindStop .Text = "Command:*Help:*^13" .Execute End With Do While .Find.Found Set Rng = .Duplicate With .Duplicate With .Find .Forward = True .Format = False .MatchWildcards = True .Text = "[^13]{2,}" .Replacement.Text = "^p" .Execute Replace:=wdReplaceAll .Text = ":[^t ]@^13" .Replacement.Text = ":^t" .Execute Replace:=wdReplaceAll .Text = "^t*^13[!^t]@^13" .Execute End With Do While .Find.Found If Not .InRange(Rng) Then Exit Do With .Paragraphs.Last.Range .InsertBefore vbTab End With .End = .Paragraphs.Last.Range.Start .Collapse wdCollapseEnd .Find.Execute Loop With Rng With .Find .Forward = True .Format = False .MatchWildcards = True .Text = "^13^t" .Replacement.Text = "¶" .Execute Replace:=wdReplaceAll End With .ConvertToTable Separator:=vbTab, NumColumns:=2, AutoFitBehavior:=wdAutoFitContent .Tables(1).Style = "Table Grid" With .Find .Text = "¶" .Replacement.Text = "^p" .Execute Replace:=wdReplaceAll End With End With End With .Collapse wdCollapseEnd .Find.Execute Loop End With End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]()
Thanks Macropod, works perfectly.
I have added a macro to make sure the fonts are as i want them The part i cant reverse engineer from the script was the top row, command:, the text after the description of the command didnt move to the second row. (everything else did) What do i change to capture the text after Command: as well ( the command part is written 'command: ' (a space after the colon) (without quotes) whereas the other elements have ° (a nonbreaking space) Thanks for your help... i havent tested it on the 1000 pager yet, but on 4 pages works like a dream ![]() |
![]() |
Tags |
vba macro, word 2016 |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Referencing text blocks from one document in several | chrisr34000 | Word | 2 | 07-05-2017 03:17 PM |
![]() |
bnyamin | Word VBA | 6 | 05-25-2017 12:15 AM |
![]() |
tcoggins | Word Tables | 2 | 06-29-2016 10:28 AM |
![]() |
rsrasc | Word VBA | 5 | 12-18-2015 07:13 AM |
![]() |
oraenthu | Word | 8 | 03-17-2015 10:22 AM |