Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Automation error: "the specified module could not be found"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pau Larsen - 01 Nov 2004 16:55 GMT
Hi,

I am trying to automat Word 2003 SP1 from a C# application.

When instantiating Word I am getting an error saying: “the specified module
could not be found".

I have added the Microsoft Word Object Library as a reference for my project
and set the following include statement: “using Word =
Microsoft.Office.Interop.Word;”.

I have tried two different approaches to get the Word instance. Both found
on the internet from working examples:

From http://blogs.msdn.com/duncanma/archive/2003/05/11/6862.aspx:
-------------------------
Word.ApplicationClass oWord = new Word.ApplicationClass();
-------------------------

From http://support.microsoft.com/kb/316384/EN-US/:
-------------------------
Word._Application oWord;
oWord = new Word.Application();
-------------------------

Everything compiles fine but in both cases the error occurs in the line of
code trying to create the Word instance.

I have been searching the web like crazy without finding any useful info. I
have tried to lower my macro security settings but that did not change a
thing (I did not really expect that anyway).

Any suggestions for what to try are very welcome.

/Pau Larsen
Pau Larsen - 03 Nov 2004 13:50 GMT
I can now add some more information to my list of experiences:

I have tried the same approach in both C# and VB.NET and I have tried to
compile with the .NET 1.1 SP1 framework using VS.NET 2003 and with the .NET
2.0 beta framework using VS.NET 2005 beta – same result everytime.

I have reinstalled Microsoft scripting components without that solving
anything after reading this
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q
_20970348.html#10938546


Then I found this article suggesting the use of VB.NET “CreateObject” to
initialize Word
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q
_20910583.html


It focused on the second parameter in the “CreateObject” call being set to
“localhost” as the solution.

I managed to use the same approach in C# using the following code:
-----------------
using Word = Microsoft.Office.Interop.Word;

….

Word.ApplicationClass word;
System.Type t = Type.GetTypeFromProgID("Word.Application", "localhost");
word = (Word.ApplicationClass)(Activator.CreateInstance(t));
----------------

I am partly happy now as I can move on. But the million dollar question
still remains unanswered in all the articles I have found. Why is the normal
way of initializing the Word instance not working on the machines I have
tested on? I am considering it “the normal way” as all code examples I have
found is using that.

I anyone have suggestions I will gladly test them?

/Pau  Larsen

> Hi,
>
[quoted text clipped - 31 lines]
>
> /Pau Larsen
 
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.