惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
The Cloudflare Blog
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
C
Check Point Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
F
Fortinet All Blogs
B
Blog
大猫的无限游戏
大猫的无限游戏
N
Netflix TechBlog - Medium
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 乐逍遥

对微软开发工具的看法 56度烟台社区 301跳转与URL转发 windows phone7 开发(Windows Phone 7 Emulator常用快捷键) Silverlight版本的微博工具 微博工具 - 乐逍遥 - 博客园 table 划线 给treeview递归增加菜单 vs2005启动时候的新闻网址 压缩文件 用c#操作Excell 数据库设计(六)概念数据模型 数据库设计(五)概念数据模型 数据库设计(四)概念数据模型 数据库设计(三)概念数据模型 数据库设计(二)概念数据模型 数据库设计系列(一)概念数据模型 电子邮件Mailto的一些参数用法 OutLook编程
c# 操作word
乐逍遥 · 2007-11-01 · via 博客园 - 乐逍遥

1.引用word 组件
2.定义word
    Word.Application app = new Word.Application();
    Word.Document doc = new Word.Document();
    app.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;object Obj_FileName = “filename”;
    object Visible = false;
    object ReadOnly = false;
         //打开文件
    doc = app.Documents.Open(ref Obj_FileName, ref missing, ref ReadOnly, ref missing,
          ref missing, ref missing, ref missing, ref missing,
          ref missing, ref missing, ref missing, ref Visible,
          ref missing, ref missing, ref missing,
          ref missing);
     doc.Activate();
3.写word文档
    //写word文档
    Word.Table tbl = doc.Tables[1];
    tbl.Cell(1,2).Range.Text=‘’;
4.拷贝数据
    Word.Bookmark myBookmark;
    object oBookmark = "a";
    myBookmark=doc.Bookmarks.get_Item(ref oBookmark);
    myBookmark.Select();
    myBookmark.Range.Copy();
5.粘贴数据
    object oMyWordStrat= doc.Content.End-1;
    Word.Range rang=doc.Range(ref oMyWordStrat,ref oMyWordStrat);
    rang.InsertBreak(ref missing);
    rang.Paste();

6.保存
    doc.Save();
    object IsSave = false;
    doc.Close(ref IsSave,ref missing,ref missing);
7.退出应用
    object IsSave = false;
    app.Quit(ref IsSave,ref missing,ref missing);
    app = null;