I have to find the text in the format or regex from the document - "([\(]){1}([0-9]){1, 2}([\)]){1}"
I want to replace the number alone found in the regex with a cross reference to the corresponding numbered item found using word macro. The only condition is that it should not take the number item with a style - "Heading1" (which has a number item to it)
For Ex: text found: "(1)" replace the text with cross reference at the number alone
The code I used throw a run time error: "Object Required".
Dim WorkPara As String
Dim CheckP() As Boolean
Dim NumPara As Integer, J As Integer
NumPara = ActiveDocument.Paragraphs.count
ReDim CheckP(NumPara)
For J = 1 To NumPara
CheckP(J) = False
WorkPara = ActiveDocument.Paragraphs(J).Range.Text
If InStr(WorkPara, regex.Pattern("([\(]){1}([0-9]){1}([\)]){1}")) > 0 Then
CheckP(J) = True
End If
Next J
For J = NumPara To 1 Step -1
If CheckP(J) Then
Selection.Range.InsertCrossReference wdRefTypeNumberedItem, wdNumberFullContext, "1"
End If
Next J
Could any one help me out with it