0

This is the Image here Following is the text with Syntax: "Question[space][1-30][colon][LineFeed]" Looks Like≔" Question 1:

The Word 2007 File is here:

https://www.dropbox.com/scl/fi/6jrbt4woc74nedafoe1r5/Sample-Document.docx?dl=0&rlkey=jo1yx3x1vvo6abr8uk833j8o6

These are the Paragraphs:

All of the Following lines are ended with Line Feed (Shift Control) Character

But The List is not bulleted

  • Discuss with your partner.
  • Question 1:
  • What ence...?
  • Answer:
  • There... together.
  • Question 2:
  • How d suggest ...”?
  • Answer:
  • The sto..either.
  • Question 3:
  • What lessons ...?
  • Answer:
  • ... them.
  • Question 4:
  • Why do you ...?
  • Answer:
  • Man is ...Scott.

About Code

  • Code will apply to document not a part
  • How to replace the last "Line Feed Character" with a Paragraph Mark.
  • Paragraph style of this be "myHead4"
  • Before Paragraph mark I want to write: (VImp) replaced by m1, (Imp2)replaced by m2, (Imp3) replaced by m4
  • Any site about Wild Card Characters
  • I am using the following code, But I failed how to use do..Loop.
  • I am using two seperate codes for this purpose
  • All this I want because I want to include Questions in my TOC.

Image is here

Sub DeleteLineFeedAndTypeParagraph()

x = Asc(Selection.text)
y = Selection.Font.Color
Selection.Words(1).Select
Selection.HomeKey
Selection.Find.ClearFormatting
    With Selection.Find
        .text = "Question [0-9]{1,2}:^l"
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute
    x = Selection.Characters.last
    If Selection.Characters.last = chr(11) Then 'vbLf Line Break
        Selection.Characters.last = vbCr
        Selection.MoveEnd unit:=wdWord, Count:=1
        Selection.Style = ActiveDocument.Styles("myHead4")
        'x = Right(Selection, 1)
    End If
End Sub
'The Second Procedure is
Sub SelectWordAndChangeText()
Selection.Words(1).Select
Select Case Selection.text
Case "m1"
Selection.text = "VImp"
Selection.Words(1).Italic = True
Case "m2"
Selection.text = "Imp"
End Select
End Sub

  • If you check the last character of these para with `Debug.Print Asc(para.Range.Characters.Last)` , it is 13 and with `If Selection.Characters.last = chr(11)` , you trying to replace 11. .. [reference](https://stackoverflow.com/questions/27223228/differences-between-vblf-vbcrlf-vbcr-constants) – Naresh Jul 12 '21 at 04:07
  • para.Range ... is returning Paragraph character that is at the end of sixth line. Please see the image. @Naresh – Anil Sharaf Jul 12 '21 at 13:06

0 Answers0