您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍了VB.NET word如何查文字,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
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如何查文字”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。