UserForms, Textboxes & Bookmarks 
Author Message
 UserForms, Textboxes & Bookmarks

Well, this is the NG for VBA beginners, so I hope no one minds stepping me
through a relatively simple problem.

[Word 97-SR2 / NT 4.0-SP4]  I have a document with several bookmarks in it
(Bkmk1, Bkmk2, Bkmk3...).  I also have a VBA form (UserForm1) with textboxes
(TextBox1...) that prompt the user for information that corresponds to the
bookmarks.  It seems like no matter how I phrase the code, the text I type
into the textbox never appears in the document.  Help!  I know that this is
possible - and the solution is probably simple - I just don't know how to
connect the two.

Thanks in Advance,
Christina

Sample Code:
    UserForm1.Show
    Selection.GoTo what:=wdGoToBookmark, Name:="Bkmk3"
    Selection.TypeText Text:=TextBox3.Text



Sat, 25 May 2002 03:00:00 GMT  
 UserForms, Textboxes & Bookmarks
From within the userform... in the OK button handler or whatever the user
presses to say ok I'm done.... use code similar to the following:

ActiveDocument.Bookmarks("Bkmk3").Range.Text = TextBox3.Text

This has the distinct disadvantage of destroying the bookmark....

you can use this code for keeping the bookmark
Dim rngBookmark As Word.Range

    Set rngBookmark = ActiveDocument.Bookmarks("Bkmk3").Range
    rngBookmark.Text = TextBox3.Text
    rngBookmark.Bookmarks.Add "Bkmk3", rngBookmark
    Set rngBookmark = Nothing

--
Will Rickards [MVP Word]
Software Engineer
http://members.home.net/wrickard

Please post ALL replies/requests to the newsgroup for the benefit of the newsgroup.
disclaimer: Use of any information/code provided is at your own risk.
My e-mail address has been modified to prevent ****.



Sat, 25 May 2002 03:00:00 GMT  
 UserForms, Textboxes & Bookmarks
I've been pounding away at this problem for days!!!  Your solution worked
like a dream ... you can't imagine how grateful I am!

Thanks so much!  Christina

Quote:

>From within the userform... in the OK button handler or whatever the user
presses to say ok
>I'm done.... use code similar to the following:
>    ActiveDocument.Bookmarks("Bkmk3").Range.Text = TextBox3.Text
>This has the distinct disadvantage of destroying the bookmark...you can use
this code for
>keeping the bookmark.

>Dim rngBookmark As Word.Range
>    Set rngBookmark = ActiveDocument.Bookmarks("Bkmk3").Range
>    rngBookmark.Text = TextBox3.Text
>    rngBookmark.Bookmarks.Add "Bkmk3", rngBookmark
>    Set rngBookmark = Nothing
>--
>Will Rickards [MVP Word]
>Software Engineer
>http://members.home.net/wrickard



Sun, 26 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. bookmarks & userforms

2. Word Bookmarks, Userforms and Updates

3. Bookmarks, References and Userforms

4. userforms for bookmarks

5. Bookmarks in userforms, how do you populate more then one place

6. Help with Bookmarks and userforms

7. two questions on how to get data entries in userforms into bookmarks (if possible at all)

8. Check Boxes, Userforms Bookmarks

9. Userforms - populating textboxes

10. Focus and textboxes on vba userforms

11. Updating textboxes in Word using UserForms fields

12. Userforms - TextBox with spell checking as you type?

 

 
Powered by phpBB® Forum Software