B
Broads
Hi I am, looking to find a solution to a problem.
I am looking to scan through XML code for a keyword and then reading the
text following this to the next ">" character.. in theory my code should
work. But I do not know word vba. I think the key point I am looking for is
the character position where the String is found... Check the following code
and please make suggestions,, evan if my approach is completely wrong......
I am looking to scan through XML code for a keyword and then reading the
text following this to the next ">" character.. in theory my code should
work. But I do not know word vba. I think the key point I am looking for is
the character position where the String is found... Check the following code
and please make suggestions,, evan if my approach is completely wrong......
Code:
Function openSearch(myfile)
Dim searchString As String
Dim curentchar As String
searchString = frmIndexGen.txtSearchString
Dim i As Integer
Dim endfound As Boolean
Dim theError As String
Documents.Open FileName:=myfile
With ActiveDocument.Content.Find
Do While .Execute(FindText:=searchString, Forward:=True,
Format:=True) = True
i = 1 ' Should be the char after the string I am looking for.
For i = 1 To ActiveDocument.Characters.Count - 1
If ActiveDocument.Characters(i) = ">" Then
endfound = True: Exit For
Else
theError = theError + ActiveDocument.Characters(i)
End If
Next i
With Documents(2).Content
.Collapse Direction:=wdCollapseEnd
.InsertParagraphAfter
.InsertAfter myfile
.Select
.InsertParagraphAfter
.InsertAfter theError
theError = ""
End With
Loop
End With
ActiveDocument.Close (False)
End Function