Visual Basic

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingVisual Basic

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old January 18th, 2011, 12:58 AM
c#9530 c#9530 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2010
Posts: 8 c#9530 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 4 m 10 sec
Reputation Power: 0
How to Use .NET Set Word Search/Find Function

In your frequently Word document, you may need search or find a certain word or phrase. Acctually, you can let your computer to do this kind of hard work especially your word document owns a large content. Maybe most of people are very familiar with this Microsoft Word advanced feature because it can save you a lot of time when you want to search or find some important data.

How to Use Word Search/Find Function?


By using Microsoft Word, you can search/find a certain word/phrase in your Word documents through two ways. First, you can use the Find command by hitting Ctrl+f which merely finds the word or phrase you're looking for. Alternatively, you can use the Find and Replace (if you want to replace the word/phrase you search) command by hitting Ctrl+h. There you can also specify the certain word/phrase that you'd like to replace and what word/phrase you want to replace it with. Both of those commands above are also can be found on the far right hand side of the Home tab, but what comes to my mind first is using the keyboard shortcuts which I think is much faster. Besides Microsoft Word, you also can use VB.NET to set Word Search/Find Function.

How to Use Spire.Doc for .NET to Set Word Search/Find Function?


Here, in order to see the result, we use highlight color to sign the text which need to be found. We use document.FindAllString method to search text. In this method, you should give four parameters: The first one is the text need to be found, the second one is used to distinguish majuscules and minuscules and the last one is used to judge whether the text which need to be replaced is a whole word or not.

Code of VB.NET from Spire.Doc for .NET :

Imports System.Drawing

Imports Spire.Doc

Imports Spire.Doc.Documents


Module Module1


Sub Main()

'Create word document

Dim document As New Document()


'load a document

document.LoadFromFile("FindAndReplace.doc")


'Find text

Dim textSelections() As TextSelection = document.FindAllString("Word", True, True)


'Set hightlight

For Each selection As TextSelection In textSelections

selection.GetAsOneRange().CharacterFormat.Highligh tColor = Color.Yellow

Next selection


'Save doc file.

document.SaveToFile("Sample.doc", FileFormat.Doc)

'Launch the file.

System.Diagnostics.Process.Start("Sample.doc")

End Sub

End Module

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingVisual Basic > How to Use .NET Set Word Search/Find Function


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap