ImageVerifierCode 换一换
格式:DOCX , 页数:3 ,大小:357.58KB ,
资源ID:22209922      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/22209922.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Understanding the Word object model from the view ofnetWord文档下载推荐.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Understanding the Word object model from the view ofnetWord文档下载推荐.docx

1、ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql 服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证 硬件维护 CPU 主板 硬盘 内存 显卡 显示器 键盘鼠标 声卡音箱 打印机 机箱电源 BIOS 网卡 C# Java Delphi 2005 当前位置: 程序开发 编程语言 .NET 临时文章 Understanding the Word Obj

2、ect Model from a .NET Developers Perspective 作者:未知 时间:2004-10-27 12:12 出处:Blog 责编:chinaitpower 摘要:暂无Summary: Provides information on how to use Microsoft Visual Studio Tools for the Microsoft Office System to take advantage of the objects available in Microsoft Office Word 2003. It introduces severa

3、l important Word objects and provides examples of how to use them. You will learn how to work with Word 2003 applications and documents, as well as with some of the more important properties and methods. (105 printed pages)Download the WordObject.exe from the Microsoft Download Center.ContentsIntrod

4、uctionGetting Started with a Word ProjectThe Underpinnings: Documents and TemplatesBirds-Eye View of the Word Object ModelThe Application ObjectThe Document ObjectThe Selection ObjectThe Range ObjectThe Bookmark ObjectSearching and Replacing TextPrintingCreating Word TablesSummaryMicrosoft Word is p

5、robably one of the most commonly used software products in the world today. Most people using Word get by just fine without writing any code at all, although Word has a rich and powerful object model making it eminently programmable. Microsoft Visual Studio Tools for the Microsoft Office System enab

6、les developers to interact with the objects provided by the Microsoft Office Word 2003 object model by using a .NET language, such as Microsoft Visual Basic .NET or Microsoft Visual C#. Word possesses a rich feature set, all of which are accessible through code. There are quite a few objects to lear

7、n about, which can be confusing when youre first getting started. Conveniently, Word objects are arranged in a hierarchical fashion, and you can get a good start on the object model by focusing on the two main classes at the top of the hierarchy, the Application and Document classes. Focus on these

8、two classes makes sense when you consider that most of the time youll either be working with the Word application itself, or manipulating Word documents in some way. As you dig into the Word object model, youll find that it emulates the Word user interface, making it easy to guess that the Applicati

9、on object provides a wrapper around the entire application, each Document object represents a single Word document, the Paragraph object corresponds to a single paragraph, and so forth. Each of these objects has many methods and properties that allow you to manipulate and interact with it. The behav

10、iors of the members of these objects are generally easy to guesshow about the PrintOut method? Others can be more obscure and sometimes tricky to use correctly. Once you learn the basics, youll find that there isnt anything you can do in the Word user interface that you cant do just as easily in cod

11、e. Programming in Word allows you to automate repetitive tasks, and to extend and customize the functionality built into Word.In this document, youll learn how to take advantage of many of the objects in Word 2003, and you will also be introduced to some of the properties, methods, and events of eac

12、h object. Youll learn how to work with Word applications and documents, as well as with some of their more important methods and properties.NoteProgramming Word and its objects from Visual Basic .NET feels much like programming in VBA. Visual Basic .NET handles optional parameters, and allows late b

13、inding, just like VBA. C#, on the other hand, provides unique challenges when programming against the Word object model. Because C# doesnt support optional parameters, parameterized properties, or late binding, youll need to handle many of the Word methods and properties specially when programming i

14、n C#. This document points out the differences between Visual Basic .NET and C# programming, as they come up.When you create a new Office project in Visual Studio .NET, you are given the option of creating a new Word Document or Word Template project, as shown in Figure 1.Figure 1. You can create ei

15、ther a Word Document or a Word Template project in Visual Studio .NET.Visual Studio .NET automatically creates a code file named ThisDocument.vb or ThisDocument.cs in your new Word project for both Document and Template projects. Open ThisDocument in your new project. Youll see that a public class n

16、amed OfficeCodeBehind has already been generated for you. Expand the hidden Generated initialization code region. The OfficeCodeBehind class includes code that wraps the Word.Document and Word.Application objects: Visual BasicFriend WithEvents ThisDocument As Word.DocumentFriend WithEvents ThisAppli

17、cation As Word.Application/ C#private Word.Application thisApplication = null;private Word.Document thisDocument = null;These two variables are declared for you: ThisDocument: Represents the Word Document object, and allows access to all of the built-in Document members in Word, including methods, p

18、roperties and events. ThisApplication: Represents the Word Application object, and allows access to all of the Application objects members, including events. The availability of these two predefined variables allows easy access to both Word objects in your code without having to declare separate Wor

19、d.Document or Word.Application objectsjust use ThisDocument and ThisApplication.Each of the following sections digs into the Document and Application objects, picking specific members of each object for demonstration. Word has a very rich object model, and it would be impossible to dig into all of t

20、he members here: Youll get enough of the flavor of the object model to be able to get started, and youll learn enough to use the Word online help for more details.TipThroughout this article, youll see many uses of the CType and DirectCast methods in the Visual Basic .NET code. The reason for this is

21、 that the sample project has its Option Strict setting onthis means that Visual Basic .NET requires strict type conversions. Many Word methods and properties return Object types: For example, the _Startup procedure is passed variables named application and document as Object types, and the CType fun

22、ction is used to explicitly convert each to Word.Application and Word.Document objects, respectively. Therefore, to be as rigorous about conversions as possible, the sample has enabled Option Strict, and handles each type conversion explicitly. If youre a C# developer reading this document, youll li

23、kely appreciate this decision. However, as youll see later on, there are certain Word features that dont translate well into the object-oriented paradigmit can sometimes be more convenient to work with Option Strict off. For the most part, youll want to work with Option Strict on; youll learn about

24、the few exceptions as they arise.Before you can effectively program Word, you need to understand how Word works. Most of the actions youll perform in code have equivalents in the user interface on the menus and toolbars. There is also an underlying architecture that provides structure to those UI ch

25、oices. One of the most important concepts is the idea of templates. You probably are already familiar with the concept of a templatea Word template can contain boilerplate text and styles as well as code, toolbars, keyboard shortcuts and AutoText entries. Whenever you create a new Word document, it

26、is based on a template, which is distinguished by the .dot file name extensionWord documents have a .doc filename extension. The new document is linked to the template, and has access to all template items. If you do not specify a custom template, any new documents you create will be based on the No

27、rmal.dot default template, which is installed when you install Word. About Normal.dotThe Normal.dot template is global in scope, and is available to every document you create. You could, if you wanted to, put all of your code in the Normal.dot and base all of the documents in your environment on you

28、r Normal template. But the file could become quite large, so for many developers, a better solution is to create customized templates for specific applications. Documents created using your custom template still have access to the code in the default Normal template. In fact, you can attach a docume

29、nt to more than one custom template in addition to Normal if you so desire. Templates and Your CodeYou are not limited to templates as containers for styles and code; you can also customize and write code in individual documents without affecting the content of the template the document is based on.

30、 When Word runs your code, it uses the fully qualified reference of the source (which can be a template or the document), the module name, and the procedure name. This operates in a similar fashion to namespaces, keeping procedures separated. Figure 2 shows the Customize dialog box for toolbars, ill

31、ustrating this concept. Each procedure is fully qualified with the name of the project, the module, and the procedure name. In this case, the item selected in the right pane refers to a procedure named TileVertical that is contained in the Tile module in Normal.dot. The SaveDocument procedure listed immediately below it is contained in the active do

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1