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;
精彩评论