2011-06-09 41 views
3

我试图用我创建(QRCode.png)图片在Word中的图片与C#

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);  
} 

回答