当前位置:编程学习 > C#/ASP.NET >>

C# 处理Word技术

string fileName = @"文件路径";
            Object Nothing = System.Reflection.Missing.Value;

//生成操作对象
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
            Microsoft.Office.Interop.Word.Document document;

Object FileName = fileName;

//打开文件
            document = wordApp.Documents.Open(ref FileName, ref Nothing, ref f, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
                    ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);

int parNum = document.Paragraphs.Count;

 for (n = 1; n <= parNum; n++)
                {
                    document.Paragraphs[n].Range.Font.Size = 12.0f;//可以设置其他大小的字体
                    document.Paragraphs[n].Range.Font.Name = "宋体";//可以设置其他字体

                    document1.Paragraphs[n].Range.Font.Color = WdColor.wdColorBlue;//字体设置为蓝色

                    document1.Paragraphs[n].Range.Font.Color = WdColor.wdColorRed;//字体设置为红色

                }

 //关闭document文档对象
document.Close(ref Nothing, ref Nothing, ref Nothing);
 //关闭wordApp组件对象
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
--------------------编程问答-------------------- 什么问题呢? --------------------编程问答-------------------- 如何把某一段设置为标题一属性 --------------------编程问答-------------------- word模板添加书签。查询书签设置数据
if(Doc.Bookmarks.Exists("a"))
{
object b="a";
Word.Bookmark bk=Doc.Bookmarks.Item(ref b);
} --------------------编程问答-------------------- --------------------编程问答-------------------- 学习!
关注! --------------------编程问答-------------------- 关注 up --------------------编程问答-------------------- 学习,帮顶! --------------------编程问答-------------------- 学习,帮顶 --------------------编程问答-------------------- 你要问什么问题?

C# word控件编程  --------------------编程问答-------------------- 我要问的是C# Word 编程问题  我要用程序自动把一篇文章中标题二变成文章的标题一
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,