office.interop을 사용하여 단어 문서 스타일의 글꼴 색상을 변경하려고하지만 색상이 변경되지 않습니다. 어떤 생각? 두 가지 방법으로 시도해 보았습니다. 제 1 회는 MS 워드에서 제목 스타일의 색상을 변경하려고하는 것입니다 :워드 문서 스타일에서 글꼴 색상을 변경하는 방법
Application appWord=new Application();
Document doc=new Document();
ListGallery gallery=appWord.ListGalleries[WdListGalleryType.wdNumberGallery];
ListTemplate template =gallery.ListTemplates[4];
Style style=doc.ListTemplate[2];
style.LinkToListTemplate(template,1);
style.Font.ColorIndex=WdColorIndex.WdBlack;//doesn't work
doc.saveAs2(path);
제 2 방법은 MS에 파일을 삽입 한 후 범위 또는 선택의 색상을 설정하려고하는 것입니다 : 는 여기에 몇 가지 코드입니다 문서 :
Paragraph p3 = wordDocument.Paragraphs.Add();
Range r3 = p3.Range;
//r3.Font.TextColor = WdColor.wdColorBlack;
var filename=String.Format("{0}Resources/TEST1.html", AppDomain.CurrentDomain.BaseDirectory);
String newString=System.IO.File.ReadAllText(filename).Replace("</body>","<p>1</p></body>");
System.IO.File.WriteAllText(filename, newString);
appWord.Selection.Font.ColorIndex = WdColorIndex.wdBrightGreen;
r3.InsertFile(filename);
//r3.Font.olorIndex = WdColorIndex.wdBrightGreen;
편집 :
: 여기는 솔루션입니다 여기
:
감사
가능한 복제 [프로그래밍 방식으로 MS 워드에서 텍스트 스타일을 설정하는 방법?] (http://stackoverflow.com/questions/17888104/how-programatically-set-text-styling-in-ms- 단어) – RajeeshMenoth
@rajeeshmenoth 꽤 똑같은 것은 아닙니다. 스타일의 기본 색상을 변경하고 싶을뿐입니다. 내가 단어 범위에 HTML 파일을 삽입 원인! html 파일에는 제목 스타일이 포함되어 있습니다!, – maryam