2014-02-14 2 views
2

사용자 지정 작업 창 (또는 모든 종류의 도킹 사용자 정의 컨트롤)을 단어 문서에 추가하는 방법을 배우려하고 있으며 내가 찾는 모든 예가 VSTO 관련입니다 .Word에 사용자 지정 작업 창 추가 (VSTO 사용하지 않음)

도와 드릴 수 있으면 VSTO를 사용하고 싶지 않습니다.

가능합니까? 누구든지 나를 올바른 장소로 안내 할 수 있습니까?

내 목표는 특정 문서와 관련된 추가 메타 데이터에 대한 양식을 제시하는 데 도움이되는 경우 문서를이 메타 데이터가 포함되어야하는지 안되는지 이미 인식 할 수 있으므로 양식을 제시하는 경우입니다. (SQL 또는 SharePoint로) 캡처 할 수 있습니다.

     

당신이 그것을 필요로하는 경우에 현재 코드입니다. . .

public class WordApplication : Extensibility.IDTExtensibility2 
{ 
    private Microsoft.Office.Interop.Word.Application WordApp; 

    public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) 
    { 
     WordApp = Application as Microsoft.Office.Interop.Word.Application; 
     WordApp.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(WordApp_DocumentOpen); 
    } 

    void WordApp_DocumentOpen(Word.Document Doc) 
    { 
     if (isPaneRequired(Doc)) 
     { 
      ShowSomeSortOfPane(); 
     } 
    } 

    private bool isPaneRequired(Word.Document Doc) { return true; } //Lots of code not needed for example. 

    private void ShowSomeSortOfPane() 
    { 
     //What goes here? 
    } 

    public void OnDisconnection(Extensibility.ext_DisconnectMode RemoveMode, ref Array custom) { } 
    public void OnStartupComplete(ref Array custom) { } 
    public void OnAddInsUpdate(ref Array custom) { } 
    public void OnBeginShutdown(ref Array custom) { } 
} 

답변

1

는 언제나처럼 나는 30 분 후에 답을 찾을 후 자신을 질문하고, 뭔가를 googleing 3 시간 보내!

Microsoft.Office.Core에서 ICustomTaskPaneConsumer을 상속 내가이 생산하는 약간의 예를 쥐게 CTPFactoryAvailable

를 구현해야 http://www.shulerent.com/2011/01/23/adding-task-panes-in-a-office-add-in-when-using-idtextensibility2/을 분류 얻기에 매우 중요했다.

public class WordApplication : Extensibility.IDTExtensibility2 
{ 
    private Microsoft.Office.Interop.Word.Application WordApp; 
    private ICTPFactory myCtpFactory; 
    private CustomTaskPane myPane; 
    private tskPane myControl; //My UserControl 

    public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) 
    { 
     WordApp = Application as Microsoft.Office.Interop.Word.Application; 
     WordApp.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(WordApp_DocumentOpen); 
    } 

    public void CTPFactoryAvailable(ICTPFactory CTPFactoryInst) 
    { 
     myCtpFactory = CTPFactoryInst; 
    } 

    void WordApp_DocumentOpen(Word.Document Doc) 
    { 
     if (isPaneRequired(Doc)) ShowSomeSortOfPane(); 
    } 

    private bool isPaneRequired(Word.Document Doc) { return true; } //Lots of code not needed for example. 

    private void ShowSomeSortOfPane() 
    { 
     myPane = myCtpFactory.CreateCTP("NameSpace.UserControlClassName", "My Task Pane", Type.Missing); 
     myPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight; 
     myControl = (tskPane)myPane.ContentControl; 

     myControl.CustomProperty = CustomValue; 
     myPane.Visible = true; 

    } 

    public void OnDisconnection(Extensibility.ext_DisconnectMode RemoveMode, ref Array custom) { } 
    public void OnStartupComplete(ref Array custom) { } 
    public void OnAddInsUpdate(ref Array custom) { } 
    public void OnBeginShutdown(ref Array custom) { } 
}