自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

C#操作Word的一點認識

開發(fā) 后端
C#操作Word的一點認識主要向你介紹了C#操作Word的內(nèi)涵,以及C#操作Word的具體的方法的應用解析。

C#操作Word的內(nèi)涵:C#操作Office套件的時候都需要用到COM組件,需要在項目里添加相應的COM組件。用C#在Word里查找指定關鍵字的方法有兩種:Selection對象和Range對象。

C#操作Word之Selection對象的用法:

  1. // C#  
  2.  internal void SelectionFind()  
  3. {  
  4.   string strFind = "find me";  
  5.   Word.Find fnd = ThisApplication.Selection.Find;  
  6.    fnd.ClearFormatting();  
  7.    fnd.Text = strFind;  
  8.   object missingValue = Type.Missing;  
  9.  
  10.   if (fnd.Execute(ref missingValue, ref missingValue,  
  11.     ref missingValue, ref missingValue, ref missingValue,  
  12.     ref missingValue, ref missingValue, ref missingValue,  
  13.     ref missingValue, ref missingValue, ref missingValue,  
  14.     ref missingValue, ref missingValue, ref missingValue,  
  15.     ref missingValue))  
  16.  {  
  17.  MessageBox.Show("Text found.");  
  18.   }  
  19.   else 
  20.   {  
  21.  MessageBox.Show("The text could not be located.");  
  22.    }  

C#操作Word之Range對象的用法:

  1. // C#  
  2.     internal void RangeFind()  
  3.    {  
  4. Word.Range rng = ThisDocument.Paragraphs[2].Range;  
  5. Word.Find fnd = rng.Find;  
  6. fnd.ClearFormatting();  
  7. object missingValue = Type.Missing;  
  8. object findStr = "find me";  
  9. if (fnd.Execute(ref findStr,   
  10. ref missingValue, ref missingValue,  
  11.     ref missingValue, ref missingValue, ref missingValue,  
  12.     ref missingValue, ref missingValue, ref missingValue,  
  13.     ref missingValue, ref missingValue, ref missingValue,  
  14.     ref missingValue, ref missingValue, ref missingValue))  
  15. {  
  16.   MessageBox.Show("Text found.");  
  17. }  
  18. else 
  19. {  
  20.   MessageBox.Show("Text not found.");  
  21.  }  
  22.   rng.Select();  
  23.  } 

C#操作Word的一點體會就向你介紹到這里,希望對你了解和學習C#操作Word有所幫助。

【編輯推薦】

  1. C#操作Word書簽實例淺析
  2. C#操作Word表的實例淺析
  3. C#操作Word表格的常見操作
  4. C#操作Word表格的彪悍實例
  5. C#操作Word實用實例淺析
責任編輯:仲衡 來源: ieee.org.cn
相關推薦

2009-08-18 17:20:17

C#操作符重載

2009-08-18 17:34:25

C#操作符重載應用

2009-08-19 13:49:14

C#操作注冊表

2009-09-09 10:53:25

C# MessageB

2009-08-17 18:15:23

C# 枚舉使用

2009-08-13 17:52:13

C#構(gòu)造函數(shù)

2009-08-18 13:06:17

C#枚舉類型

2009-08-27 17:50:09

interface接口

2009-08-14 11:29:28

C#創(chuàng)建Windows

2009-08-28 16:30:24

C#線程

2009-08-19 10:42:08

C#操作Word表格

2009-09-03 14:28:23

C#日期格式化

2009-08-03 09:17:30

ASP.NET Ses

2009-08-19 10:16:15

C#操作Word

2009-08-19 10:46:48

C#操作Word表格

2009-08-19 10:25:14

C#操作Word

2009-06-16 13:30:32

REST無狀態(tài)

2009-08-19 11:34:06

C#操作Word

2009-08-19 11:13:49

C#操作Word

2009-08-19 09:42:52

C#操作Word書簽
點贊
收藏

51CTO技術棧公眾號