Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jun 27, 2016 12:53 am

hello guys,

I'd like to ask you one thing that how i can search the words in doc ?

for instance, there're lots of pages in this doc, and i like to search the word like "TABLE".

i wanna get focusing when i push the "<" or ">" button as you see

Thanks for helping me.

here's the picture under below.
dff.png



and here's my code :
Code: Select all
        Dim document As New Document()
        Dim temp() As Object = Nothing
        Dim i As Integer = 0

        If RichTextBox1.Text = "" Then
            Return
        End If
        document.LoadFromFile("C:\\Users\\bangjh\\Downloads\\14S-99999_86.doc", FileFormat.Docx)

        'Find Word
        Dim textSelections() As TextSelection = document.FindAllString(RichTextBox1.Text, True, True)

        'Highlight Word
        For Each selection As TextSelection In textSelections
            selection.GetAsOneRange().CharacterFormat.HighlightColor = Color.Cyan

        Next selection

        document.SaveToFile("Find.docx", FileFormat.Docx)
        'Save and Launch
        System.Diagnostics.Process.Start("Find.docx")

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 3:23 am

Hi,

Thanks for your posting.
You can use textSelections[index+1]/textSelections[index-1] to go next/previous selection.
For example, sample code is to go next selection.
Code: Select all
Private Sub btn_after_Click(ByVal sender As Object, ByVal e As EventArgs)
        If String.IsNullOrEmpty(richTextBox1.Text) Then
            Return
        End If
        Dim document As New Document()
        document.LoadFromFile(input)
        'Find Word
        Dim textSelections As TextSelection() = document.FindAllString(richTextBox1.Text, True, True)

        'Highlight Word
        textSelections(index + 1).GetAsOneRange().CharacterFormat.HighlightColor = Color.Cyan

        document.SaveToFile("Find.doc", FileFormat.Doc)
        'Save and Launch
        System.Diagnostics.Process.Start("Find.doc")
    End Sub


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 4:38 am

Hi,

first of all, Thanks for replying me

even though I just tried it as you replied to me that code, it couldn't work well..

There's an error under below
err.png


which is mean "the file is using from the other process so that it can't be access"

i'm just wondering if i use the code what you let me know, the process starts again due to "System.Diagnostics.Process.Start("Find.doc")"

i just wanna search in one doc.. through the "<" and ">" button..

Thanks for your help !

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 6:19 am

Hi,

Please close opened file before each process starts, or you can also use different file names for output files, for example,
Code: Select all
Dim output As String = [String].Format("{0}.doc", index)
document.SaveToFile(output, FileFormat.Doc)
System.Diagnostics.Process.Start(output)


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 6:30 am

Thanks for replyng again.

i'd like to talk to you in real time .

can we chat right now? if so, plz tell me how to get in touch with you.

i really need your help now :) or i can call you right away. if you leave a phone number i'll call you .
Last edited by welcometrp on Mon Jun 27, 2016 7:17 am, edited 1 time in total.

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 6:40 am

Hi,

Voice contact is not convenient for us as there are multiple teams in same office. Can we type by Skype? Our Skype account is iceblue.support. And our e-mail is support@e-iceblue.com, you can also send your issue by e-mail.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 7:03 am

hi,

i just added iceblue.support for skype.

would you accept it?
Last edited by welcometrp on Mon Jun 27, 2016 7:16 am, edited 1 time in total.

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 7:08 am

Hi,

I have accepted it.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 7:10 am

well.. i think that i can't be touch with you in skype due to firewall in our company

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 7:13 am

Hi,

You also can send your issue to support@e-iceblue.com.
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Jun 27, 2016 7:13 am

can we chat in facebook?
there's messenger in the facebook

welcometrp
 
Posts: 6
Joined: Mon Jun 27, 2016 12:33 am

Mon Jun 27, 2016 7:24 am

Hi,

Yes, we can. Please provide us your facebook account, and we will add it.
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc