我正在尝试将我的文字替换为我创建的图片(QRCode.png)
first method()
{
//creates QRCode
Bitmap b = qCodeEncoder.Encode(encodable);
//saves it
b.Save("QrCode.png", System.Drawing.Imaging.ImageFormat.Png);
FindAndReplace(WordApp, "<QRCode>", b);
}
第二种方法是适用于文本的正常替换程序。但它不能做图像只能说System.Drawing.BitMap
;
private void FindAndReplace(
Microsoft.Office.Interop.Word.Application WordApp,
object findText,
object replaceWithText)
{
object machtCase = true;
object matchWholeWord = true;
object matchWildCards = false;
object matchSoundsLike = false;
object nmachtAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visibible = true;
object replace = 2;
object wrap = 1;
WordApp.Selection.Find.Execute(
ref findText,
ref machtCase,
ref matchWholeWord,
ref matchWildCards,
ref matchSoundsLike,
ref nmachtAllWordForms,
ref forward,
ref wrap,
ref format,
ref replaceWithText,
ref replace,
ref matchKashida,
ref matchDiacritics,
ref matchAlefHamza,
ref matchControl);
}
答案 0 :(得分:-1)
请改为查看OpenXML SDK:
http://msdn.microsoft.com/en-us/library/bb497430.aspx
它不需要安装MS Office,而且速度更快,因为它没有加载应用程序Word