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

VB.NET word查文字案例解析

開(kāi)發(fā) 后端
本文主要介紹了一個(gè)關(guān)于VB.NET word查文字的案例,代碼如Public Class ThisDocument Private MyDocMenu As Office.CommandBarButton ...。

VB.NET還是比較常用的,于是我研究了一下VB.NET word查文字,在這里拿出來(lái)和大家分享一下,希望對(duì)大家有用。

VB.NET word查文字代碼:

  1. Public Class ThisDocument  
  2. Private MyDocMenu As Office.CommandBarButton  
  3. Private missing = System.Reflection.Missing.Value  
  4. '在功能區(qū)中新增菜單組  
  5. Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup  
  6. Dim MyCommandBarPopup As Office.CommandBarPopup = Nothing 
  7. Dim MyCommandBarMenu As Office.CommandBar = CType( _  
  8. Application.CommandBars.ActiveMenuBar, Office.CommandBar)  
  9. Dim MyControlsCount As Integer = MyCommandBarMenu.Controls.Count  
  10. MyCommandBarPopup = CType(MyCommandBarMenu.Controls.Add( _  
  11. Office.MsoControlType.msoControlPopup, missing, missing, _  
  12. MyControlsCount, True), Office.CommandBarPopup)  
  13. If (MyCommandBarPopup IsNot Nothing) Then  
  14. MyCommandBarPopup.Caption = "文件管理" 
  15. MyDocMenu = CType(MyCommandBarPopup.Controls.Add( _  
  16. Office.MsoControlType.msoControlButton, missing, _  
  17. missing, missing, True), Office.CommandBarButton)  
  18. MyDocMenu.Caption = "查找文字" 
  19. AddHandler MyDocMenu.Click, AddressOf MyDocMenuCommand_Click  
  20. End If  
  21. End Sub  
  22. Private Sub ThisDocument_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown  
  23. End Sub  
  24. '查找文字  
  25. Private Sub MyDocMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)  
  26. Dim MyFind As String = "" 
  27. Dim MyFindForm As New Form1()  
  28. MyFindForm.ShowDialog()  
  29. MyFind = MyFindForm.textBox1.Text  
  30. If (MyFind.Length < 0) Then  
  31. Return  
  32. End If  
  33. Dim MyCount As Integer = 0 
  34. Dim MyDocument As Word.Document = Me.Application.ActiveDocument  
  35. Dim MyRange As Word.Range = MyDocument.Content  
  36. MyRange.Find.ClearFormatting()  
  37. MyRange.Find.Forward = True 
  38. MyRange.Find.Text = MyFind 
  39. MyRange.Find.Execute(missing, missing, missing, missing, missing, _  
  40. missing, missing, missing, missing, missing, _  
  41. missing, missing, missing, missing, missing)  
  42. While (MyRange.Find.Found)  
  43. MyRange.Bold = 1 
  44. MyCountMyCount = MyCount + 1  
  45. MyRange.Find.Execute(missing, missing, missing, missing, _  
  46. missing, missing, missing, missing, missing, missing, _  
  47. missing, missing, missing, missing, missing)  
  48. End While  
  49. MessageBox.Show(MyFind + "一共找到:" + MyCount.ToString() + "個(gè)!", _  
  50. "51cto信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)  
  51. End Sub  
  52. End Class 

以上是VB.NET word查文字的一個(gè)案例,大家可以試試。

【編輯推薦】

  1. 剖析VB.NET平臺(tái)調(diào)用是如何執(zhí)行操作
  2. 分享個(gè)人總結(jié)VB.NET多線程
  3. 詳細(xì)說(shuō)明VB.NET變量中四點(diǎn)
  4. 三類十二種VB.NET數(shù)據(jù)類型全面介紹
  5. VB.NET初步知識(shí),初學(xué)者必看
責(zé)任編輯:田樹(shù) 來(lái)源: 樂(lè)博網(wǎng)
相關(guān)推薦

2009-10-29 14:02:24

VB和VB.NET比較

2010-01-12 11:17:21

VB.NET文字特效

2009-10-26 17:38:22

VB.NET實(shí)現(xiàn)縮略圖

2009-10-09 15:59:41

VB.NET對(duì)象

2010-01-21 14:49:44

VB.NET操作Wor

2010-01-21 16:37:56

VB.NET變量聲明

2010-01-14 17:41:57

VB.NET變量范圍

2010-01-08 15:33:57

VB.NET文字寬度計(jì)

2009-11-02 14:48:45

VB.NET HOOK

2010-01-15 16:46:05

VB.NET集合存儲(chǔ)

2009-11-02 10:53:34

VB.NET INI文

2009-11-03 10:18:46

VB.NET繼承

2009-10-20 16:17:37

VB.NET Word

2010-01-11 17:40:36

VB.NET相框效果

2010-01-08 17:12:03

VB.NET短路判斷

2010-01-19 15:08:18

VB.NET對(duì)象成員

2009-10-29 13:46:14

VB.NET DES加

2010-01-15 16:12:40

VB.NET調(diào)用DLL

2009-10-14 14:19:00

VB.NET創(chuàng)建表示層

2010-01-18 18:06:07

VB.NET多線程
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)