This is first instance of using named parameters in calling the underlying COM functionality. Line 6: Open up the Word document we are interested in.Line 1: Open Word application object found in the namespace.( (_Application)ap ).Quit( SaveChanges: false, OriginalFormat: false, RouteDocument: false ) ap.Quit( SaveChanges: false, OriginalFormat: false, RouteDocument: false ) Ambiguity between method '._Application.Quit(ref object, ref object, ref object)' and non-method '.ApplicationEvents4_Event.Quit'. The example code below uses an existing document at C:\TestDoc.docx.ĭocument doc = ap.Documents.Open( ReadOnly: false, Visible: false ) Ĭonsole.WriteLine( "Selection type not handled no writing done" ) ĭoc.RemoveDocumentInformation( WdRemoveDocInfoType.wdRDIAll ) Īp.Documents.Save( NoPrompt: true, OriginalFormat: true ) Ĭonsole.WriteLine( "Unable to acquire Selection.no writing to document done." ) Īp.Documents.Close( SaveChanges: false, OriginalFormat: false, RouteDocument: false ) Ĭonsole.WriteLine( "Exception Caught: " ex.Message ) // Could be that the document is already open (/) or Word is in Memory(?) Note you can use version 12 or version 14 but you might as well use the latest 14. In the Solutions Explorer right click on the References folder and select Add Reference.In VS2010 create a Console Application.Why the developer no longer has to reference null when passing in optional parameters to COM objects thanks to.Properly cast method calls to specific interops to avoid “Ambiguity between method” issue CS0467 C# compiler warning.Properly close the Word Application and clean up resources opened by the underlying Office Interop calls.Open and properly close a Word Document.This article gives a step by step view of how to open a word document without needing the tools of Visual Studio Tools for Office (VSTO). Net 4, working with the office interops has become a lot easier.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |