要操作word,我们就需要word的对象库文件“msword.olb”(word 2000为msword9.olb),通常安装了office word后,你就可以在office安装目录的office10文件夹下面找到这个文件,当我们将这个文件引入到项目后,我们就可以在源码中使用各种操作函数来操作word.具体做法是打开菜单栏中的项目>添加引用>浏览,在打开的“选择组件”对话框中找到msword.olb后按确定即可引入此对象库文件,vs.net将会自动将 库文件转化为dll组件,这样我们只要在源码中创建该组件对象即可达到操作word的目的!
using system; 【程序编程相关:为什么程序员不应调用“sun”包?(译文】
在cs代码文件中对命名空间的应用,如:using word;范例如下: 【推荐阅读:Struts1.1 介绍 】
using system.collections; 【扩展信息:用VS.NET2003制作MSI安装程序】using system.drawing; using system.componentmodel; using system.windows.forms; using word;namespace examsecure
{ /// /// itemtodoc 的摘要说明. /// 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 窗体设计器支持所必需的 // initializecomponent(); ... 下一页