引用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);
}
}
winform嵌入Word并根据光标执行插入操作
猜你喜欢
转载自blog.csdn.net/qq_35106907/article/details/84955000
今日推荐
周排行