如何用word文档中的图像替换字符串 [英] how to replace string with image in word document
问题描述
如何用图像替换word文档中的字符串
我试过这样的
< pre lang =cs> foreach (Word.Range docRange in docTemp.Words)
{
if (docRange.Text.Trim()。Equals( 签名,
StringComparison.CurrentCultureIgnoreCase))
{
string signaturePath = Properties.Settings.Default.SFolderPath + \\Signatures\\signature.png跨度>;
Word.InlineShape pic = docRange.InlineShapes.AddPicture(signaturePath);
}
}
但是插入的图片没有替换字符串签名 。在插入图像之前,需要选择要插入图片的范围;)
如何:以编程方式定义和选择文档中的范围 [ ^ ]
如何:定义和选择文档中的范围 [< a href =http://msdn.microsoft.com/en-us/library/2a9dt54a%28v=vs.80%29.aspxtarget =_ blanktitle =New Window> ^ ]
How to replace string in word document with image
I have tried like this
foreach (Word.Range docRange in docTemp.Words)
{
if (docRange.Text.Trim().Equals("signature",
StringComparison.CurrentCultureIgnoreCase))
{
string signaturePath = Properties.Settings.Default.SFolderPath + "\\Signatures\\signature.png";
Word.InlineShape pic = docRange.InlineShapes.AddPicture(signaturePath);
}
}
but its inserting image not replacing string "signature".
Before you insert an image, you need to select range in which you want to insert picture ;)
How to: Programmatically Define and Select Ranges in Documents[^]
How to: Define and Select Ranges in Documents[^]
这篇关于如何用word文档中的图像替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!