Results 1 to 12 of 12

Thread: [RESOLVED] textboxes to a bookmark

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Resolved [RESOLVED] textboxes to a bookmark

    I have a document and I was wondering was there a way that I could type text onto the document and it gets copied into the text box i have created at real time. Thanks
    Last edited by Hack; Apr 20th, 2006 at 08:16 AM. Reason: Added [RESOLVED] to thread title and green "resolved" checkmark

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Document - TextBox

    well the closest I could get was this:
    I cant find a "Keypress" event.... will keep looking though

    VB Code:
    1. Dim WithEvents WDoc As Word.Application
    2.  
    3. Private Sub Form_Load()
    4.     Dim wrd As New Word.Application
    5.     wrd.Documents.Add
    6.     Set WDoc = wrd.Application
    7.    
    8.     WDoc.Visible = True
    9. End Sub
    10.  
    11. Private Sub Form_Unload(Cancel As Integer)
    12.     WDoc.Quit
    13. End Sub
    14.  
    15.  
    16. Private Sub WDoc_WindowSelectionChange(ByVal Sel As Word.Selection)
    17.     Text1 = Sel
    18. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: Document - TextBox

    Well i am now trying to copy text entered into the textbox and put it into the bookmark. I can get it working partially but it says it inserts before and is a pain. Is there anyway I can get it just to copy the normal text.

    VB Code:
    1. Private Sub Document_New()
    2.  
    3. End Sub
    4.  
    5. Private Sub TextBox1_Change()
    6.    With ActiveDocument
    7.   .Bookmarks("test1").range.InsertBefore TextBox1.Text
    8.  
    9. End With
    10.  
    11. End Sub
    Last edited by caz1805; Apr 19th, 2006 at 11:36 AM.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: textboxes to a bookmark

    .Type

    SOrry.. word is not my strong suit as far as Office goes...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: textboxes to a bookmark

    what do you mean with .type?

    I tried it instead of .Insertbefore but it created an error.

    thanks alot static.

    caz

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: textboxes to a bookmark

    wasnt sure...

    I know when u record a macro in word and type some words.. it used blah.blah.type "words etc" or something like that.. worth a shot sorry

    try recording a macro.... and then look at the code (ALT+F11)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: textboxes to a bookmark

    yeh i could try that but still got to make the link between the textbox and the bookmark which i can tdo without vba. Thanks anyway mate.

    Here is the code i have just got but with the same errors for some reason and underneath is the output.

    VB Code:
    1. Private Sub TextBox1_Change()
    2. With ActiveDocument
    3.     .Bookmarks("test1").range.Text = TextBox1.Text
    4.  
    5. End With
    6. End Sub

    Input in textbox: hello
    Ouput at bookmark: hellohellhelheh




    caz
    Last edited by caz1805; Apr 19th, 2006 at 01:08 PM.

  8. #8
    Lively Member New2vba's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    95

    Re: textboxes to a bookmark

    The problem here is that the change event will fire off everytime you make a change so you type "h", bookmark = "h", you then type "e" so you have "he" in your text box, which again is added to the bookmark giving you "heh" and so on.

    Not sure how you will get round this, but I'm sure someone can offer you some direction. Maybe you can fire the event with a keypress or a command button instead?
    Last edited by New2vba; Apr 19th, 2006 at 02:29 PM.
    "Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: textboxes to a bookmark

    Thanks New2VBA, yeh that figures now. Making it on a vbKeySPace still had the problem with updating everything in the textbox.

    Do you know anyway of using autocorrect in a document and showing both the old text and the changed text at the same time.

    thanks for that.

    caz

  10. #10
    Lively Member New2vba's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    95

    Re: textboxes to a bookmark

    Sorry I don't, although if you search autocorrect in vba help there seems to be quite a lot of information, including examples.
    "Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: textboxes to a bookmark

    DO you think i could send info from a bookmark into a textbox?

    caz

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    88

    Re: textboxes to a bookmark

    solved thanks for all the help

Posting Permissions

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



Click Here to Expand Forum to Full Width