Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2005

Tip: Looking for answers? Try searching our database.

Getting "FileNotFoundException" when initialize a Word ApplicationCalass variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ksskumar2000@gmail.com - 03 Oct 2005 12:08 GMT
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.
Richard T. Edwards - 03 Oct 2005 11:44 GMT
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,
>
[quoted text clipped - 31 lines]
> runtime.  But I am getting this error at the initial stage itself.
> Please help me.
Ron - 03 Oct 2005 23:07 GMT
Make this change:

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

... and it'll work

> Hi,
>
[quoted text clipped - 31 lines]
> runtime.  But I am getting this error at the initial stage itself.
> Please help me.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.