2017-01-11 1 views
0

헤더 또는 바닥 글을 삽입하고 C#을 통해 addin vsto라는 단어를 사용하여 페이지의 측면에 수직으로 정렬하고 싶습니다. 다음은 내가보고자하는 최종 결과의 예입니다. 나는 이것을 연구하려고 시도했는데이 프로그램을 수행하는 일부 예를 찾을 수 없었습니다. 아무도 이것을 달성하는 방법을 알고 있습니까?"사이드"머리말이나 꼬리말을 추가하고 단어 추가 기능과 수직으로 정렬하는 방법 C#?

enter image description here

그래서 지금은 텍스트 상자를 삽입, 그리고 난과 같이 페이지 측면에 정렬 할 수 있습니다하지만 내 최종 사용자가 선택하거나 삭제할 수 싶지 않아요. 그래서 솔루션을 "측면"머리글이나 바닥 글에 넣을 것이라고 생각하고 있습니다 ...하지만 이제는 문제가 어떻게 동일한 정렬 및 위치를 얻을 수 있습니까?

답변

0

그래서 내 자신의 질문에 대답합니다. 현재 활성 문서와 머리글에서 "머리글"을 얻을 수 있지만 맨 위에있는 것처럼 보이지만 실제로는 아무 것도 저장할 수있는 전체 문서에 걸쳐 있습니다 (어도비 사진관의 레이어라고 생각할 수 있음). 어쨌든이 헤더 레이어에 삽입하고 텍스트 상자를 세로로 정렬하려면 다음을 사용하십시오.

//note: we are in ThisAddin.cs (word addin) and this.Application = word addin 

private void drawTdCycleTextBox(String cycleCode) 
     { 
      int length = 1000; 

      // get the current cursor location 
      Range cursorRange = this.Application.Selection.Range; 

      // get the primary header on the current page 
      HeaderFooter header = this.Application.ActiveDocument.Sections.First.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]; 
      // header.Range.Text = "THIS IS A TEST"; 

      // create the textbox inside the header and at the current cursor location 
      Microsoft.Office.Interop.Word.Shape textBox = header.Shapes.AddTextbox(Office.MsoTextOrientation.msoTextOrientationUpward, 0, 0, 35, length, cursorRange); 
      textBox.TextFrame.TextRange.Font.Size = 20; 
      textBox.TextFrame.TextRange.Text = Util.repeatedTextOutput(cycleCode, 25, length); 
      textBox.Fill.ForeColor.RGB = ColorTranslator.ToOle(Color.Turquoise); 
      textBox.Fill.Transparency = .35F; 
     } 
관련 문제