Hello,
I have been trying to do something with ASPOSE words that I have done previously using MS word and that is to replace an existing shape with another shape from a file. This used to be done doing something like the following where the relevant shape had been named via a macro.
Dim sNewPicture As Microsoft.Office.Interop.Word.Shape
Dim sFileName as String = "C:\Temp\test.bmp"
For Each oPicture In oWordAppl.ActiveDocument.Shapes
If oPicture.Name = "Photo" Then
oPicture.Select()
sNewPicture = myWordApp.ActiveDocument.Shapes.AddPicture(FileName:=sFileName, Left:=oPicture.Left, Top:=oPicture.Top, Width:=oPicture.Width, Height:=oPicture.Height, Anchor:=myWordApp.Selection.Range)
oPicture.Delete()
End If
Next oPicture
I have tried to do something similar with aspose as per the following
Dim shapes As Aspose.Words.NodeCollection = oDoc.GetChildNodes(NodeType.Shape, True, False)
Dim shape As Aspose.Words.Drawing.Shape
Dim insertShape As Aspose.Words.Drawing.Shape
For Each shape In shapes
If shape.HasImage Then
If shape.ImageData.ImageType = Drawing.ImageType.Jpeg Then
insertShape = builder.InsertImage("C:\Temp\test.bmp")
insertShape.Top = shape.Top
insertShape.Left = shape.Left
insertShape.Width = shape.Width
insertShape.Height = shape.Height
shape.Remove()
End If
End If
Next
however without much luck - I have attached the document I am working off and the picture to be replaced is in the top left corner "Place Photo Here".
Can you please offer any suggestions?
thanks
Simon
