Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Sandeep Mewara 10-Oct-12 11:42am    
What error?
arshad alam 11-Oct-12 2:19am    
are you creating custom task pane?

1 solution

Its solved by declaring static variable in AddIns project
C#
public partial class ThisAddIn
   {
       public static Word.Application app;
   }


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


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

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900