Replacing text in Word using C #

I am trying to replace my text with the picture 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);
}

The second method is a normal substitute for text that works. But he cannot make images that he speaks only 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);      
}
+3
source share
1 answer

Take a look at the OpenXML SDK:
http://msdn.microsoft.com/en-us/library/bb497430.aspx

MS Office is not required and it is faster because it does not load the application Word

-1
source

All Articles