Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selection TypeText (2000)

    I know (selection.typetext tex:="some text") is used to type current text on the screen. I also know in selection.typeext tex:="some text", recognizes each character. I want to know what can I use for only word. I want only word to recognize, not character. For instance watch for space after typing.

    This is what I want to do. I use a dictionary of object to stores some keys and items. It woks in Visual Basic. When a user types a key, the item replaces the key automatically. This is the line of code I use in VB to do that in conjunction with textchange

    If DictData.Exists(Text1.Text) Then Text1.Text = DictData(Text1.Text) & vbCrlf

    Every time a user types a key and the key exisits in the dictionary, it gets replaced by the item automatically. I want to know how can I replaced the above line in Word with something like selection.typtext or selection.words. I want when a user types a word in Word and the word is a key that exist in the dictionary of object, it should get replaced by the ithem automatically.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Selection TypeText (2000)

    Can't you use the AutoCorrect feature of Word? It replaces words that occur in a list by replacement text.
    See here for a description of how to export AutoCorrect entries so that they can be transferred to another computer.

    As an alternative, you could use the AutoText feature. AutoText entries are stored in a template, so it's easy to distribute them.

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection TypeText (2000)

    I don't want to use the autocorrect entry for what I am doing. I prefer to use the dictionary of object.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection TypeText (2000)

    The Dictionary object is not part of VBA but may be used via the Scripting runtime.

    Add a Project reference to Microsoft Scripting Runtime and then use something like

    <pre> Dim dicObject As Scripting.Dictionary
    Set dicObject = New Dictionary
    With dicObject
    ' Do stuff here
    End With
    Set dicObject = Nothing
    </pre>


  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection TypeText (2000)

    I already had this part work. I want to know if I can use selection.typetext or selection.words in order when I type the keys for the items to retrieve automatically. It works fine in VB, but not in word.

    If DictData.Exists(selection.typetext text::=.keys) Then (selection.typetext text:=.keys) = DictData(selection.typetext text:=.itemst)

    this is what I want to do. Since selection.typtext recognize characters not words. I want to know what I can do make it recognize words. For example, watch for space.

    I want Words to monitor words that are being typed. If these words (keys) exist in the dictionary, I want them to be repaced automatically by the items. I want to know what should I do make Word monitors words that are being typed.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection TypeText (2000)

    Have you looked at the WindowSelectionChange event?

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Selection TypeText (2000)

    Okay, now, think about this: Selection.TypeText is a programmatic method to insert something to the current Selection. The user's activities have no relation to this method.

    Did you follow the link in <!post=Post #152191,152191>Post #152191<!/post>? If you follow that thread, you see that Klaus Linke demonstrates how to attach a macro to a key, specifically the spacebar (<!post=Post #114359,114359>Post #114359<!/post>). There are other ways to end a word, of course, including a variety of punctuation marks. You could intercept all of these. Now the challenge for you is that not only do you have to detect an "end of word" character, you have to read the "word" previous to that character and replace it before entering the user's character, but only if the user is working in a document attached to your template. Once your template is unloaded, the macro won't exist and the keybinding will generate an error. Therefore, you also need to clear the keybinding when your template closes. A wide variety of usability issues are addressed through the rest of that very long thread.

    Hope this helps.

  8. #8
    Star Lounger
    Join Date
    Apr 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Selection TypeText (2000)

    I got you. I would like to watch for space. For example, space bar will determine the end of a word. The macro will be attached to a template. When the template is closed, the macro is also destroyed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •