I want to replace a placeholder in a Word document by an image using:
Dim document As WordDocument = New WordDocument("Template.docx")Dim myTextSelection as TextSelection = document.Find("MyPlaceHolder", False, False)
Dim paragraph As WParagraph = New WParagraph(document)
Dim picture As WPicture = CType(paragraph.AppendPicture(Image.FromFile("C:\MyImage.png")), WPicture)
Dim newSelection As TextSelection = New TextSelection(paragraph, 0, 1)
Dim bodyPart As TextBodyPart = New TextBodyPart(document)
bodyPart.BodyItems.Add(paragraph)
document.Replace(textSelection.SelectedText, bodyPart, True, True)
But instead of loading wPicture from a file, I would like to load it from a memorystream or a PictureBox.Image. I know it must be simple but I can't figure it out. Can anyone provide guidance? Thanks !