【问题标题】:C# - Microsoft word interop find text replace with pictureC# - Microsoft word interop 查找文本替换为图片
【发布时间】:2015-05-22 10:14:03
【问题描述】:

如何在word文档中查找文字并将文字替换为图片?我知道怎么用文字代替文字,但是有没有用图片代替文字呢?

【问题讨论】:

  • 用文本替换文本的代码是什么?

标签: c# image text replace office-interop


【解决方案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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2019-08-13
    • 1970-01-01
    相关资源
    最近更新 更多