如何在word文档中找到文本并用图片替换文本?我知道如何用文本替换文本,但是无论如何用文字替换文本?
答案 0 :(得分:1)
如果您要替换的文字有一个有效的Word.Range
对象,则可以使用InlineShapes.AddPicture()
。
例如:
// Get the Range for the text you want to replace, which you claim to be able to do already.
Word.Range selectedText = GetTextToReplace();
// Clear the existing text, otherwise the image will just be appended after the text.
selectedText.Text = "";
// Insert the image.
selecetdText.InlineShapes.AddPicture(imagePath, Type.Missing, true, Type.Missing);