c#實現VSTO 在游標處填充內容
Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;//獲取當前最新一個開啟的文件
Selection focusSelect = Globals.ThisAddIn.Application.Selection; //獲取游標位置
int start1 = focusSelect.Start;
int end2 = focusSelect.End;
focusSelect.TypeText(text);
InlineShape inlineShape = focusSelect.InlineShapes.AddPicture(@"本地圖片路徑");
focusSelect.InlineShapes.AddPicture(@"網路圖片路徑");
//inlineShape.Width = 20;
//inlineShape.Height = 20;
int start = focusSelect.Start;
int end = focusSelect.End;
focusSelect.TypeParagraph(); //新增一個段落
Range range = focusSelect.Range;
// Range range = doc.Range();
range.Tables.Add(range, 4, 3);
Table table = range.Tables[1];
table.set_Style("網格型");
table.Cell(1, 1).Range.Text = "姓名";
table.Cell(1, 2).Range.Text = "角色";
table.Cell(1, 3).Range.Text = "學歷";