473,799 Members | 3,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Clos e(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.DocumentE vents2_Event.Cl ose'
Ambiguity between method 'Word._Applicat ion.Quit(ref object, ref object, ref
object)' and non-method 'Word.Applicati onEvents4_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 9075
> The following lines...

objWordDoc.Clos e(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.DocumentE vents2_Event.Cl ose'
Ambiguity between method 'Word._Applicat ion.Quit(ref object, ref object, ref
object)' and non-method 'Word.Applicati onEvents4_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)obj WordDoc).Close( ...);
((_Application) objWordApp).Qui t(...);

Jan 3 '06 #2

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

Similar topics

6
3312
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 class, Assembly class, and Material class as follows... Site Class (clsSite): Option Explicit
24
9905
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 id="MyTest" style="position:absolute;top:0px;left:0;height:12;width:12;text-align:center">'+MyString+'</div>'); Now if MyString contains 6 characters, I end up with 6 <div id="MyTest"> containers. With IE I am able to access these containers as...
3
2326
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 on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the behavior is like MSN Messenger. But one problem arose. When I close the form (the first time), it...
4
15857
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 write a VB script, to be executed either within Access or executed at the CMD prompt, which will loop through all the records and open the document object and save it to a Word document that I can access from Windows Explorer. An additional info...
102
5722
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 can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
10
4030
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
0
1373
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 screen as i change the embedded object for the OLE. 2. After a few times of selecting different template from the combo box, ms word prompt error message "insuffiecient memory - component cannot be display properly" My code is written as below: ...
2
2441
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) System.Runtime.InteropServices.Marshal.ReleaseComObject(objPDFDistiller) objPDFDistiller = Nothing
1
2091
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 and close bound control then open the next doc. Each time I open the doc an instance of winword is opened in the background, however, when I close the bound control object (doc_container) the winword instance is not closed and is still running....
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.