문제

MicroSft Word 문서에서 보고서를 생성하기 위해 C#에 코드를 작성하고 있습니다.

  • Wid 2 열의 테이블이 있습니다.
  • 두 번째 열을 선택합니다

    Omaintable.Cell (CurrentRownumber, 2) .Range

  • 해당 셀에 무언가를 쓸 때마다 위의 코드를 텍스트 속성, insertparagraph (), insertAfter () 등의 조합과 함께 사용합니다.

이제이 콘텐츠가 있다고 가정 해 봅시다.

일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠.

New Paragraph Some sample content Some sample content Some sample

콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠

Some Title1

New Paragraph Some sample content Some sample content Some sample

콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠

New Paragraph Some sample content Some sample content Some sample

콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠 일부 샘플 콘텐츠

Some Title1

나는 전체 범위에 적용되지 않도록 somitle1 및 simitle2에 밑줄과 대담한 이탤릭체를 적용하고 싶습니다. 이 두 텍스트 줄로만 제한되어 있습니다.

도움이 있습니까?

감사

도움이 되었습니까?

해결책

먼저 면책 조항을 만들어 드리겠습니다 ;-) "** 여기에 제시된 솔루션은 내 히트와 시험 접근 및 헤드 뱅킹의 결과입니다 **"

    object srchText="Text to be searched and formatted differently from the rest of the range";
    oTable.Cell(countRow, 2).Range.Select();
    var selectUpdateComment=oTable.Cell(countRow, 2).Range.Application.Selection;
    selectUpdateComment.Find.Execute2007(ref srchText, ref missing, ref missing,
 ref missing, ref missing, ref missing, ref missing, ref missing,
 ref missing, ref missing, ref missing, ref missing, ref missing,
 ref missing, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing);

    if(selectUpdateComment.Find.Found) {
        selectUpdateComment.Font.Bold=1;
        selectUpdateComment.Font.Underline=WdUnderline.wdUnderlineSingle;
    }

나는 이것을 루프로하고 있었기 때문에 범위를 할 때마다 선언한다면, 그렇지 않으면 올바른 선택을 얻지 못할 것입니다.

더 나은 접근법을 제안 해주세요 ..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top