Trouble Instantiating Word Object in VB.NET

P

Phil Galey

On the following web page:

http://www.duncanmackenzie.net/blog/Word-Automation-from-C-vs-VBNET/

it is stated that the following code works successfully in VB.NET:

Dim wordApp As New Word.Application()
Dim newDoc As Word.Document = wordApp.Documents.Add
newDoc.Range.Text = "Test"
newDoc.AttachedTemplate = "C:\....\Macmillan.dot"
wordApp.Visible = True

however, I am not able to get it to work. I'm using VB.NET 2002 on Windows
2000 Pro, with MSWord 2000 installed. When I run the above code, I receive
a "Call was rejected by callee" error. I referenced Word 9.0 object
library. I also tried running the code with Word open and with Word closed,
but the result is the same. Any idea why I am not able to instantiate the
Word application and how to get it to work? It works ok in VB6, but not in
VB.NET. Thanks.

Phillip
 
P

Perry

Try to replace this
Dim wordApp As New Word.Application()
by
Dim wordApp As New Word.ApplicationClass()


--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
P

Phil Galey

I had tried ApplicationClass and just tried it again and it gives the same
error: "Call was rejected by callee." So Perry, does instantiating of the
Word application work on your system with VB.NET? It does work for me in
VB6, but not in VB.NET for some reason. I also tried
CreateObject("Word.Application"), but that also fails, saying "Cannot create
ActiveX object."
 
P

Perry

So Perry, does instantiating of the
Word application work on your system with VB.NET?

No problems here.

Looks more like an installation issue than a technical coding issue to me.

Have you tried the posing this question to newsgroup:
microsoft.public.dotnet.framework.setup

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top