How to get number of selcted text in MS word

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darith
    New Member
    • Mar 2008
    • 4

    How to get number of selcted text in MS word

    Hi all, I want to know code in vb.net to get number of selected text in MS Word.

    how can we write? Please help me. I need it urgent.

    in textbox we just write textbox.selecte dtext so we can get number of selected text but in MS word i don't understand how can we write to get number selcted text in MS word?

    one problem in textbox if we want to start selction we just write textbox.selecti onstart, but if we want ms word start selection text like this textbox. what code should we write? Please help me.

    Thank for your helping.

    Darith.
  • maheshmrk22
    New Member
    • Dec 2007
    • 23

    #2
    Hi,

    I did not get your question. Do you want to say that you try to access the word file from your local system. and with application you try to get number of selected words in that file.


    Thanks,
    Mahesh




    Originally posted by darith
    Hi all, I want to know code in vb.net to get number of selected text in MS Word.

    how can we write? Please help me. I need it urgent.

    in textbox we just write textbox.selecte dtext so we can get number of selected text but in MS word i don't understand how can we write to get number selcted text in MS word?

    one problem in textbox if we want to start selction we just write textbox.selecti onstart, but if we want ms word start selection text like this textbox. what code should we write? Please help me.

    Thank for your helping.

    Darith.

    Comment

    • darith
      New Member
      • Mar 2008
      • 4

      #3
      Thank so much for your helping.

      your coding is not match that i want. i want code in vb.net to get number of selected text in MS word.

      For example,

      Imports Microsoft.Offic e.Core
      Imports Microsoft.Offic e.Interop

      Dim wapp As Word.Applicatio n
      Dim wdoc As Word.Document
      wapp = GetObject(, "Word.Applicati on")
      wapp = Nothing
      wdoc = wapp.ActiveDocu ment
      wapp.Visible = True
      wapp.activedocu ment.range.text 'if i write like this i will get all text from MS word, but i want to get only selected word in MS word, for example, In Ms word it contains "The computer Science" so i want to get only word that i selected. if i select the word "computer" in MS word then i want vb.net code to returns computer " word that i selected". In textbox we just write textbox.selecte d, but i don't know code to get from ms word. please help me.

      Thank very much.

      Comment

      • maheshmrk22
        New Member
        • Dec 2007
        • 23

        #4
        Hi,

        I think you can try by taking help of object of Clipboard. I think that can give you the text that you have copied but i am not sure that will that give you text that you just selected and not copied. One more thing you can do is, You can simply simply copy the selected data on clipboard and then retrive it from there.

        Thanks
        Mahesh



        Originally posted by darith
        Thank so much for your helping.

        your coding is not match that i want. i want code in vb.net to get number of selected text in MS word.

        For example,

        Imports Microsoft.Offic e.Core
        Imports Microsoft.Offic e.Interop

        Dim wapp As Word.Applicatio n
        Dim wdoc As Word.Document
        wapp = GetObject(, "Word.Applicati on")
        wapp = Nothing
        wdoc = wapp.ActiveDocu ment
        wapp.Visible = True
        wapp.activedocu ment.range.text 'if i write like this i will get all text from MS word, but i want to get only selected word in MS word, for example, In Ms word it contains "The computer Science" so i want to get only word that i selected. if i select the word "computer" in MS word then i want vb.net code to returns computer " word that i selected". In textbox we just write textbox.selecte d, but i don't know code to get from ms word. please help me.

        Thank very much.

        Comment

        • vanc
          Recognized Expert New Member
          • Mar 2007
          • 211

          #5
          Google this "Word Automation" will give you heaps of links that can help you work out your question. Cheers.

          Comment

          Working...