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. Maximum number of entries possibl

2. How do i insert a record between two existing records (DATA ENTRY QUESTION)

3. Question on Bookmarks and AutoText entries

4. Question on Bookmarks and AutoText Entries

5. Question on Bookmarks and AutoText Entries

6. Data Entry & Bookmarks

7. getting data from Acc97, bookmarks and blank lines

8. Two questions: handling data on multiple worksheets with single data source

9. Two questions: handling data on multiple worksheets with single data source

10. Word Bookmarks, Userforms and Updates


 
Powered by phpBB® Forum Software © phpBB Group