Use .NET Operation Word

xiaoxiao2021-03-06  84

To operate Word, we need Word's object library file "msword.olb" (Word 2000 for msword9.olb), and you can find this file below the Office Word in Office Word, when you are installed. After we introduce this file into the project, we can use various operational functions in the source code to operate Word. The specific approach is to open items in the menu bar> Add reference> Browse, find this object library file after finding msword.olb in the "Select Components" dialog box, VS.NET will automatically transform the library file For the DLL component so that we can achieve the purpose of operating Word as long as you create this component object in the source code!

Application CS namespace code file, such as: using Word; Example follows: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using Word; namespace ExamSecure { // /// ItemTodoc's summary description. /// public class ItemToDoc: System.Windows.Forms.Form {object strFileName; Object Nothing; Word.ApplicationClass myWordApp = new Word.ApplicationClass (); Word.Document myWordDoc; string strContent = ""; private System.ComponentModel.Container Components = NULL; Public ITEMTODOC () {// // Windows Form Designer Support for // InitializationComponent (); // // td: Add any constructor code after INITIALIZEComponent call //} [stathread] static Void main () {system.windows.forms.Application.run (new itemtodoc ());} // / / / / Clean all the resources being used. /// Protected {if (disponents! = Null) {components.dispose ();}}.

#REGION Windows Form Designer Generated Code // / / / Designer Support for Method - Do not use the code editor to modify the // this method. /// private vid initializecomponent () {/// temtodoc // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (292, 273); this. Name = "itemtodoc"; this.text = "itemtodoc"; this.Load = new system.eventhandler (this.itemtodoc_load);

转载请注明原文地址:https://www.9cbs.com/read-122601.html

New Post(0)