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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot quit Word application

Status
Not open for further replies.

erixire

Technical User
Jun 4, 2002
72
CA
Hi,

I have some difficulties using the quit command for a word application. Here is my code:

Dim WORDapp As Word.Application
WORDapp = CreateObject("WORD.Application")
WORDapp.Visible() = True
...some code here...
WORDapp.Quit()
WORDapp = Nothing

The problem is that Visual Studio doesn't want to accept my "WORDapp.Quit()". I have the error message:

'Quit' is ambiguous across the inherited interfaces 'Word._Application' and 'Word.ApplicationEvents2_Event'.

I use the Microsoft Word 9.0 Object library. All I want to do is to quit word at the end of my code. I searched through this site, but it seems like everybode use the ".Quit()" without problems. Can somebody help me?



 
I noticed your declaration was set up like this:

Code:
Dim WORDapp As Word.Application
WORDapp = CreateObject("WORD.Application")

I had to do this with Access... try declaring WORDapp as type "Object".

Code:
Dim WORDapp As Object
WORDapp = CreateObject("WORD.Application")

I'm no expert on Office automation, but it looks like you've got 2 different namespaces that are colliding because of the declaration... if you just declare it as "Object", it won't have the extra one to deal with. Like I said, I'm not sure if that's the answer, but it's worth a shot...

Ben
 
I tried with the "As Object" method and it works. The thing is that ".Quit" wasn't in the list member, so I tought it wouldn't work. I also tried to cast with "CType" as "Word._application" and it worked too. So thanks a lot.
 
Yeah, I know it's not in the list... kinda freaked me out the first time I did it. I don't know why... but when you're using those Office Automations, you just kinda have to know what functions are available, because they don't all show up... I saw it on a website & did the good ol' <ctrl> C <ctrl> V... that's how I discovered that it worked.
 
Do you know of any good websites with examples of using Word in .NET. As I will be doing a simular thing soon

Thanks in advance

Matt
 
Sorry Matt... nothing here. I've automated a little in Access and I'm doing a project now in Excel, but never Word. Mostly I just Google'd to get what I know now... sometimes blind squirrels DO find nuts [tongue]

Have you found any good sites, erixire?

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top