View Single Post
 
Old 01-19-2023, 07:36 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Your <some text to be ignored> didn't appear in your sample doc. If you provide some real examples of the text to be ignored we can offer some other methods of dealing with them. I still think that it can be a ConvertToTable method but we need to identify the pattern of correcting that extra paragraph of data.

Perhaps this code will sort out the columns correctly. If that works it should be easy to remove the extra columns either before or after making it a table.
Code:
Sub MacroTest()
  With ActiveDocument.Range.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "(Cake description:•)^l([!^13]{1,})^13([!^13]{1,})^13Color"
    .Replacement.Text = "\1^p\2^p^p\3^pColor"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
    .Text = "^l"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
  End With
  Selection.WholeStory
  Selection.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=10, NumRows:=3, AutoFitBehavior:=wdAutoFitFixed
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote