Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Quit() command doesn't work

Status
Not open for further replies.

capitano

Programmer
Jul 30, 2001
88
US
I'm just learning to program MS Word from VB.NET and getting errors when I try to call the quit command. Can someone help? I'm following the examples in the book Mastering Visual Basic .NET. I'm doing this:

Dim WordApp As New Word.Application()
Dim newDoc As New Word.Document()
newDoc = WordApp.Documents.Add
newDoc.SaveAs("MyVBWordDoc")

...do stuff....

WordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
WordApp.Quit()

I get a compiler error over the WordApp.Quit() saying:
"Quit is ambiguous across the inherited interfaces 'Word._Application'and
'Word.ApplicationEvents2_Event'"

What does that mean and what should I do about it? I'm a little miffed because I'm just following the example code out of the book and it's not working.

Thanks for any help,
Bryan

 
Dear Bryan,

just to explain not to solve:

There is a method called "quit" in the class word.Application and there is an event called "quit".

So in fact the 'compiler' does not know which one to invoke.

Is the book about .Net or about Word or both??
as there is no problem with the Code in VBA for Word.


regards Astrid
 
Thanks, I figured the problem was something like that. The book I'm looking at is about VB.NET. I've looked in 2 different books and they both use this Quit() method the same way.

I'm not sure how tell the compiler which quit() method to invoke.

Any ideas from the VB.NET programmers out there?

Thanks,
Bryan
 
try below
Dim WordApp As New Word.ApplicationClass()
Dim newDoc As New Word.DocumentClass()

instead of
Dim WordApp As New Word.Application()
Dim newDoc As New Word.Document()
 
It turns out some changes just moments before the final release of VB.NET made this change:

Instead of:
Dim WordApp As New Word.Application()

It should actually be:
Dim WordApp As New Word._Application()

Now when you call WordApp.Quit(), it will actually quit without complaining.

Just thought I should pass on this tidbit for others.

Bryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top