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

Hi,

Two questions

1.
I have created a VBA Userform with a listbox, an up and a down arrow, and
an OK and a Cancel button.
Using Userform_Initialize I load the listbox with a number of items, let's
say: Amsterdam, Berlin, London.
After using the up and down arrow they appear in a different order; Berlin,
London, Amsterdam.

Is it possible without selecting any item to export this list to a Word
document in such a way that every item from the listbox is assigned to a
separate bookmark.

So a predefined Word document could be something like this:

My favourite European cities are:

1.      Berlin  ( = bookmark)
2.      London (= bookmark)
3.      Amsterdam ( = bookmark)

2. Second question:
How does one export entries, from textboxes in a multi-page form, into
bookmarks that appear in a Word document?!

Trying all kinds of things, I haven't succeeded so far.

Hope anyone knows the answer.

Ben



Fri, 09 May 2003 03:00:00 GMT  
 two questions on how to get data entries in userforms into bookmarks (if possible at all)
Hi Ben,

Quote:
> 1.
> I have created a VBA Userform with a listbox, an up and a down arrow, and
> an OK and a Cancel button.
> Using Userform_Initialize I load the listbox with a number of items, let's
> say: Amsterdam, Berlin, London.
> After using the up and down arrow they appear in a different order;
Berlin,
> London, Amsterdam.

> Is it possible without selecting any item to export this list to a Word
> document in such a way that every item from the listbox is assigned to a
> separate bookmark.

So you want to use every item from the listbox to a bookmark, no matter what
the user chooses but in the order they are appearing in the listbox itself?
In the following code I assume that there are exactly the same number of
bookmarks in the document (Bookmark1, Bookmark2 and Bookmark3 etc) as the
number of items in the listbox:
------------------------------------------------------------------------
Dim i As Integer
Dim sNameBookmark As String

  For i = 1 To ListBox1.ListCount
    sNameBookmark = "Bookmark" & i
    ActiveDocument.Bookmarks(sNameBookmark).Range.Text = _
                   ListBox1.List(i - 1)
  Next i
  ------------------------------------------------------------------------

Quote:
> 2. Second question:
> How does one export entries, from textboxes in a multi-page form, into
> bookmarks that appear in a Word document?!

Same way as in a normal form:
------------------------------------------------------------------------
Dim oRange As Range

  'Check to see if the bookmark is there
  If ActiveDocument.Bookmarks.Exists("Bookmark1") Then
    Set oRange = ActiveDocument.Bookmarks("Bookmark1").Range
    oRange.Text = TextBox1.Text
    'The bookmark is gone now, so you need to add it again
    ActiveDocument.Bookmarks.Add name:="Bookmark1", Range:=oRange
  End If
  Set oRange = Nothing
------------------------------------------------------------------------

Hope this helps,
regards,
Astrid

For direct access to all Microsoft newsgroups:



Fri, 09 May 2003 03:00:00 GMT  
 two questions on how to get data entries in userforms into bookmarks (if possible at all)
There are some excellent articles on using bookmarks in VBA on the MVP FAQ
site. You might want to check them out.

http://www.mvps.org/word

--
Charles Kenyon

Word New User FAQ & Web Directory:
http://www.addbalance.com/word

Legal Users Guide (modified)
http://www.addbalance.com/usersguide
 --------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Quote:
> Hi,

> Two questions

> 1.
> I have created a VBA Userform with a listbox, an up and a down arrow, and
> an OK and a Cancel button.
> Using Userform_Initialize I load the listbox with a number of items, let's
> say: Amsterdam, Berlin, London.
> After using the up and down arrow they appear in a different order;
Berlin,
> London, Amsterdam.

> Is it possible without selecting any item to export this list to a Word
> document in such a way that every item from the listbox is assigned to a
> separate bookmark.

> So a predefined Word document could be something like this:

> My favourite European cities are:

> 1. Berlin  ( = bookmark)
> 2. London (= bookmark)
> 3. Amsterdam ( = bookmark)

> 2. Second question:
> How does one export entries, from textboxes in a multi-page form, into
> bookmarks that appear in a Word document?!

> Trying all kinds of things, I haven't succeeded so far.

> Hope anyone knows the answer.

> Ben



Fri, 09 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Data Entry to two seperate tables from one control simultaneously

2. Word Bookmarks, Userforms and Updates

3. Bookmarks, References and Userforms

4. userforms for bookmarks

5. UserForms, Textboxes & Bookmarks

6. bookmarks & userforms

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

8. Help with Bookmarks and userforms

9. Check Boxes, Userforms Bookmarks

10. Getting data from two different databases at a time

11. Getting data from two tables in different databases

12. Getting data from two different Access files

 

 
Powered by phpBB® Forum Software