winform嵌入Word並根據游標執行插入操作
阿新 • • 發佈:2018-12-12
引用dsoFramer.ocx(並放入system32),先管理員執行cmd註冊regsvr32 dsoframer.ocx(64位放入SysWow64) using Words = Microsoft.Office.Interop.Word; private void OperationWord_Load(object sender, EventArgs e) { if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "2.docx")) { this.axFramerControl1.Open(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "2.docx"); } } private void Button1_Click(object sender, EventArgs e) { var temp = this.axFramerControl1.ActiveDocument as Words.Document; Words.Application app = temp.Application; if(app != null ) { Words.Selection selection = app.Selection; selection.InsertAfter(textBox1.Text); } }