Hi Aspose Team,
My problem is probably a minor one.
I want to replace a graphic and a text string in the header of a document.
The following code works fine, the image is replaced and the text is found and replaced. However I only want to replace the text once in the header only. The replace method as I have it replaces all occurances of the text in the whole document.
' Open document.
Dim doc As New Aspose.Words.Document("c:\downloads\Research.docx")
Dim regex As New System.Text.RegularExpressions.Regex("Research")
Dim shape As Aspose.Words.Drawing.Shape = DirectCast(doc.GetChild(Aspose.Words.NodeType.Shape, 0, True), Aspose.Words.Drawing.Shape)
If shape.HasImage Then
shape.ImageData.SetImage("C:\downloads\pic8.jpg")
End If
doc.Range.Replace(regex, "stringx")
' Save output document.
doc.Save("c:\downloads\out.doc")