I’m trying to replace my Text with a picture that I created (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);
}
Second method is a normal replacer for text that works. But it can’t do images it only says 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);
}
Take a look at OpenXML SDK instead:
http://msdn.microsoft.com/en-us/library/bb497430.aspx
It doesn’t need MS Office installed, and it’s faster because it doesn’t load the application
Word