Thanks for all your help.
So, the paragraphs which contained timecodes but no other text did not contain three spaces...
Probably a moronic solution but, after various experimentation, this worked:
Sub converttotable() 'add three spaces after timecodes in blank paragraphs Dim myStoryRange As Range For Each myStoryRange In ActiveDocument.StoryRanges With myStoryRange.Find .ClearFormatting .MatchWildcards = True .Execute findtext:="(^13[0-9][0-9]:[0-9][0-9]:[0-9][0-9])(^13)", ReplaceWith:="\1 ^p", Replace:=wdReplaceAll 'turn three spaces into ~ character .MatchWildcards = False .Execute findtext:=" ", ReplaceWith:="~", Replace:=wdReplaceAll End With Next myStoryRange 'turn ~ characters into columns Selection.WholeStory Application.DefaultTableSeparator = "~" Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _ NumColumns:=2, AutoFitBehavior:=wdAutoFitFixed With Selection.Tables(1) .Style = "Table Grid" .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False End With 'remove top, bottom and horizontal border lines Selection.Tables(1).Select Selection.Tables(1).AutoFitBehavior (wdAutoFitContent) Selection.Tables(1).AutoFitBehavior (wdAutoFitContent) Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone Selection.HomeKey Unit:=wdStory End Sub




Reply With Quote
