We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fill TextBox (MSO) Shape in Word Document with Image - Set Display Image of TextBox C# VB .NET

Hi! I’m trying to iterate all the shapes (of type .msoTextBox) of my word document and change the Fill of all shapes to an UserPicture. I know to to do it in VBA but I’m new to the apose product and have no idea where to start, can you help me please?
That’s the code in vba:

 Dim picname As String 
 Set objShapes = ActiveDocument.Shapes
 For i = objShapes.Count To 1 step -1
    if objShapes(i).AlternativeText = "*SIGNATURE*" Then
        picname = Pathapp & Application.PathSeparator & "FICS" & Application.PathSeparator & "SIGN" & FORMAT(sgnnumber,"00000") & ".bmp"
        if FileExists(picname) Then
            with objShapes(i)
              .TextFrame.TextRange.Text = ""
              .Line.Visible = False
           end with
        End if
     End if
 Next i


Thanks for your interest in Aspose.Words API. Please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Your expected document (DOCX file) showing the desired output. You can create this document by using MS Word and attach it here for our reference

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.

I’ve provided you with a simpler VBA in DOC, when you manually start Sub Change_TextBox_for_BMP() , it changes the fill to the bmp.example.zip (73.3 KB)

Sorry , I forgot to include the picture of the desired result after macro execution. I’ve attached to this message.2020-02-03_18-38-57.jpg (26.3 KB)


You can build logic on the following C# code of Aspose.Words for .NET to set / fill the image of a TextBox Shape to display:

Document doc = new Document("E:\\Temp\\Example\\1.docm");

foreach(Shape shape in doc.GetChildNodes(NodeType.Shape, true))
    if (shape.AlternativeText == "*SIGNATURE*")
        if (shape.CanHaveImage)


Hi, Many thanks for your help, that’s a great way to manage images in shapes
regardless of their type.


Thanks for your feedback. In case you have further inquiries or may need any help in future, please let us know.