VSTO-this.Application.Documents.Open在WinForm中不起作用 [英] VSTO - this.Application.Documents.Open not working in WinForm

查看:84
本文介绍了VSTO-this.Application.Documents.Open在WinForm中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

如果我使用"this.Application.Documents.Open(@"C:\ Test \ NewDocument.docx",ReadOnly:true);在VSTO addIns中-它的工作

但是在同一项目中但在WinForm上却给出了错误.

如果有人对此有任何想法,请提供帮助.

问候,
YRishi

Dear All,

If i use "this.Application.Documents.Open(@"C:\Test\NewDocument.docx", ReadOnly: true);" in VSTO addIns - Its work''s

But in same project but on WinForm its gives error.

Please help if anyone have idea on this.

Regards,
YRishi

推荐答案

通过在AddIns项目中声明静态变量来解决
public partial class ThisAddIn
   {
       public static Word.Application app;
   }





private void ThisAddIn_Startup(object sender, System.EventArgs e)
   {
        app = this.Application;
   }



声明静态变量后,我可以在winform lavel上接收所有属性



After declaring static variable, I am able to receive all properties on winform lavel

private void button1_Click(object sender, EventArgs e)
{
   ThisAddIn.app.Documents.Open(directoryName + editFileName);
}


这篇关于VSTO-this.Application.Documents.Open在WinForm中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆