VB.NETword如何查文字
这篇文章主要介绍了VB.NET word如何查文字,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
创新互联-专业网站定制、快速模板网站建设、高性价比台州网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式台州网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖台州地区。费用合理售后完善,十年实体公司更值得信赖。
VB.NET word查文字代码:
Public Class ThisDocument Private MyDocMenu As Office.CommandBarButton Private missing = System.Reflection.Missing.Value '在功能区中新增菜单组 Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup Dim MyCommandBarPopup As Office.CommandBarPopup = Nothing Dim MyCommandBarMenu As Office.CommandBar = CType( _ Application.CommandBars.ActiveMenuBar, Office.CommandBar) Dim MyControlsCount As Integer = MyCommandBarMenu.Controls.Count MyCommandBarPopup = CType(MyCommandBarMenu.Controls.Add( _ Office.MsoControlType.msoControlPopup, missing, missing, _ MyControlsCount, True), Office.CommandBarPopup) If (MyCommandBarPopup IsNot Nothing) Then MyCommandBarPopup.Caption = "文件管理" MyDocMenu = CType(MyCommandBarPopup.Controls.Add( _ Office.MsoControlType.msoControlButton, missing, _ missing, missing, True), Office.CommandBarButton) MyDocMenu.Caption = "查找文字" AddHandler MyDocMenu.Click, AddressOf MyDocMenuCommand_Click End If End Sub Private Sub ThisDocument_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub '查找文字 Private Sub MyDocMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Dim MyFind As String = "" Dim MyFindForm As New Form1() MyFindForm.ShowDialog() MyFind = MyFindForm.textBox1.Text If (MyFind.Length < 0) Then Return End If Dim MyCount As Integer = 0 Dim MyDocument As Word.Document = Me.Application.ActiveDocument Dim MyRange As Word.Range = MyDocument.Content MyRange.Find.ClearFormatting() MyRange.Find.Forward = True MyRange.Find.Text = MyFind MyRange.Find.Execute(missing, missing, missing, missing, missing, _ missing, missing, missing, missing, missing, _ missing, missing, missing, missing, missing) While (MyRange.Find.Found) MyRange.Bold = 1 MyCountMyCount = MyCount + 1 MyRange.Find.Execute(missing, missing, missing, missing, _ missing, missing, missing, missing, missing, missing, _ missing, missing, missing, missing, missing) End While MessageBox.Show(MyFind + "一共找到:" + MyCount.ToString() + "个!", _ "51cto信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class
感谢你能够认真阅读完这篇文章,希望小编分享的“VB.NET word如何查文字”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
网页题目:VB.NETword如何查文字
链接地址:http://ybzwz.com/article/psijjd.html