Getting "FileNotFoundException" when initialize a Word ApplicationCalass variable

  • Thread starter Thread starter Richard T. Edwards
  • Start date Start date
R

Richard T. Edwards

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.
 
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;
 
Make this change:

Word.Application oWordApp = new Word.Application();

.... and it'll work
 
Back
Top