我有一個Microsoft Office Word 2013加載項,其中我用鼠標在活動文檔上選擇了一些文本。如何將兩個組內容控件添加到Word中的活動文檔中 - 這不是有效的選擇
然後,我在Add In
上有一個按鈕,當我點擊它時,它應該在GroupContentControl_1中對該選擇中的所有內容進行分組。然後,它應該在GroupContentControl_1之前插入另一個GroupContentControl_2。
光標將出現在GroupContentControl_2中,用戶可以開始輸入任何內容。
我已經嘗試了很多事情,但得到錯誤:
private void Button_Click(object sender, RoutedEventArgs e)
{
//This line puts everything in current selection under a new group content control
GroupContentControl gcc1 = doc.Controls.AddGroupContentControl("A");
//Select the cursor position before the above group content control
doc.Application.Selection.SetRange(gcc1.Range.Start - 1, gcc1.Range.Start - 1);
//Insert new group content control-2 before the above one
GroupContentControl gcc2 = doc.Controls.AddGroupContentControl("B");
}
在代碼的第三行,我收到以下錯誤:
This is not a valid selection
。
同樣的問題還找不到解決方案。如果你找到一個,請讓我知道 – 2015-05-11 10:38:10