Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Populate form (W97)

    I have a form User Form that dumps the input into a doc via bookmarks.... when I reopen the form, how do I get those bookmarks to prefill the formfields?

  2. #2
    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: Populate form (W97)

    Do the bookmarks span the entire inserted text? If so, something like

    ActiveDocument.Bookmarks("bmk1").Range.Text

    should have what you need. If the bookmark only denotes the beginning of the string, I think you're in for a much tougher project.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Populate form (W97)

    <P ID="edit" class=small>(Edited by gwhitfield on 27-Sep-02 06:49. Hyperlinks added)</P>Hi jsher, you helped me with the "Protect', "Unprotect"ing of my Cover form. Its actually for the same section..... I want the userform to prepopulate with the contents of the existing bookmark when opened.
    IT was link: http://www.wopr.com/cgi-bin/w3t/showflat.p...amp;o=&vc=1

  4. #4
    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: Populate form (W97)

    A-ha! I sort of remember...

    If you are preserving the form controls, as I did in my code example in the other thread, you can use the same property, the ActiveDocument.FormFields(BookmarkName).Result to retrieve the text in the form control and assign it to your UserForm textbox. There's a nice symmetry there, eh?

    Something like:

    Me.txtBoxName.Value = myDoc.FormFields("bmkName").Result

    in the UserForm_Initialize() procedure. (Don't hold me to that name. Whatever it is, it is automatically created when you use the drop-downs at the top of the code window for your UserForm, and if you change it, Word/VBA will ignore it.)

Posting Permissions

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