开发者

Cannot implicitly convert type 'System.Drawing.Font' to 'Microsoft.Office.Interop.Word.Font'

my code :

   public class Fonts
    {
    Font Header = new System.Drawing.Font("Tahoma", 10, FontStyle.Bold);

      ToWord ToWord = new ToWord(Header);
    }



public class ToWord
{
    public ToWord(开发者_如何学PythonSystem.Drawing.Font Header)
    {
    ......

    Paragraph pIndex = DocumnetWord.Paragraphs.Add(ref oMissing);

    pIndex.Range.Font =Header;//error compile....
    }

}

error :

Cannot implicitly convert type 'System.Drawing.Font' to 'Microsoft.Office.Interop.Word.Font'

What is the correct code?


I think you will need to use the Font class properties directly to assign the appropriate values:

pIndex.Range.Font.Bold = True;
pIndex.Range.Font.Color = Word.WdColor.wdColorBlack;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜