Suggestion:
To see if its the interop issue, start a new project and add only the
reference to the Runtime.InteropServices:
using System.Runtime.InteropServices
Then in your event:
private void button2_Click(object sender, System.EventArgs e)
{
Object[] myargs = new Object[1];
myargs[0] = true;
System.Type TWord = System.Type.GetTypeFromProgID("Word.Application.9" );
System.Object WordAp = System.Activator.CreateInstance(TWord);
WordAp.GetType().InvokeMember("Visible",
System.Reflection.BindingFlags.SetProperty, null, WordAp, myargs);
}
This should create an instnace of word and set the visible property to true.
If this works -- as it does on my machine -- then there's a very good chance
you have a Microsoft.Office.Interop issue. Also, try referencing only the
Microsoft Word 11.0 Object Library, too.
hth.
<ks**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,
I have added following two reference under COM tab,
Microsoft Office 11.0 Object Library
Microsoft Word 11.0 Object Library
The software I have used:
Visual studio 1.14
Microsoft Office 2003
I have installed Office XP PIAs
My program:
using Microsoft.Office.Interop ;
using System.Runtime.InteropServices;
.
.
.
private void button2_Click(object sender, System.EventArgs e)
{
Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new
Microsoft.Office.Interop.Word.ApplicationClass();
}
The problem:
When I click the button, I got an exception,
An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in WindowsApplication1.exe
Additional information: The specified module could not be found.
What could be the problem??? I need to open a word document in the
runtime. But I am getting this error at the initial stage itself.
Please help me.