2011-06-09 42 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);  
} 

回答