473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem closing Word object from within C#

Sorry for the previous duplicate posts.

I'm referencing and using the Microsoft Word 11.0 object model from within
my VS 2005 C# Windows app.

The following lines...

objWordDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Quit(ref missing, ref missing, ref missing);

Give me the following errors:

Ambiguity between method 'Word._Document.Close(ref object, ref object, ref
object)' and non-method 'Word.DocumentEvents2_Event.Close'
Ambiguity between method 'Word._Application.Quit(ref object, ref object, ref
object)' and non-method 'Word.ApplicationEvents4_Event.Quit'

So I can't seem to close Word. Any idea how to get around it?

Thanks for any help!
Ron

Jan 3 '06 #1
1 9046
> The following lines...

objWordDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Quit(ref missing, ref missing, ref missing);

Give me the following errors:

Ambiguity between method 'Word._Document.Close(ref object, ref object, ref
object)' and non-method 'Word.DocumentEvents2_Event.Close'
Ambiguity between method 'Word._Application.Quit(ref object, ref object, ref
object)' and non-method 'Word.ApplicationEvents4_Event.Quit'


Those should just be warnings from the compiler, rather than errors; it
should still be able to build the code in theory, as it can resolve the
ambiguity by making a method group and using the matching overload.

The problem is because the objects expose a Close/Quit method and a
Close/Quit event, declared in different interfaces so they can have the
same name. So, you should just need to cast down to the correct
interface, like
((_Document)objWordDoc).Close(...);
((_Application)objWordApp).Quit(...);

Jan 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Iain Bishop | last post by:
I'm trying to model objects for the following problem: A building site contains assemblies, each of which can contain other assemblies and/or materials. I have modelled this using a Site...
24
by: Robi | last post by:
I have the following problem: I populate a page with a specific amount of <div id="MyTest"> containers inside another <div> container. for (i=0; i < MyString.length; i++) document.write('<div...
3
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click...
4
by: Otis Hunter | last post by:
I have been given an Access Database which contains a table that has an OLE object field that contains a Word document. That table contains hundreds of records. I would like to find out how I can...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
0
by: Austen | last post by:
I have developt an application which will show word template in the OLE object as user selected the template from a combo box. But the problem occured as below: 1. The OLE doesnt refresh the...
2
by: Joe | last post by:
in my Class1 Form: Dim objPDFDistiller = CreateObject("PdfDistiller.PdfDistiller.1") in my Form1_FormClosed (main form that I am closing) ...
1
by: nassersh | last post by:
I am using a bound control to embed word documents within an access form. I have created two buttons on the form One to embed aand display and one to close. I embed one doc and then save the doc...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.