如何用word文档中的图像替换字符串 [英] how to replace string with image in word document

查看:81
本文介绍了如何用word文档中的图像替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何用图像替换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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆