Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Using ListBox to populate many REF fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DieSpammersDie - 25 Oct 2005 06:25 GMT
I have a word template for which I have created a userform.  The template
has bookmarks (call them BOOK1, BOOK2 and ITEM1,ITEM2) which are repeated
many times throughout the template.  I have used the REFERENCE to only have
the user input data into one user field and then have the document populated
with the user input.  BOOK1 and BOOK2 are simple text boxes and everything
is working great there.  All of the REF for BOOK1 and BOOK2 get populated in
the document.

However, the ListBox selection only populates the actual bookmark and DOES
NOT populate any of the REF to ITEM1_ITEM2.  I am not sure why and have just
about lost all patience with the ListBox populating the REF in the document.

Here is the pertinent part of the code:

Private Sub UserForm_Initialize()
ListBox1.List = Array("ITEM1", "ITEM2")
ListBox1.ListIndex = 0

If ListBox1.ListIndex >= 0 Then
   With ActiveDocument
       .Bookmarks("ITEM1_ITEM2").Range.InsertBefore ListBox1.Text
   End With
Else
   MsgBox "You must select an item first"
End If
End Sub

Thanks for your help.
Charles Kenyon - 25 Oct 2005 16:37 GMT
http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm and
http://word.mvps.org/FAQs/MacrosVBA/WorkWithBookmarks.htm should answer your
questions. You are probably either deleting the bookmarks or inserting your
text outside the bookmarks. See also
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm.
Signature

Charles Kenyon

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

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.

>I have a word template for which I have created a userform.  The template
> has bookmarks (call them BOOK1, BOOK2 and ITEM1,ITEM2) which are repeated
[quoted text clipped - 29 lines]
>
> Thanks for your help.
Doug Robbins - Word MVP - 25 Oct 2005 20:58 GMT
Use

  With ActiveDocument
       .Variables("ITEM1_ITEM2").Value = ListBox1.Text
       .Fields.Update
   End With

and insert { DocVariable ITEM1_ITEM2 } where ever you want the information
to appear.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have a word template for which I have created a userform.  The template
> has bookmarks (call them BOOK1, BOOK2 and ITEM1,ITEM2) which are repeated
[quoted text clipped - 29 lines]
>
> Thanks for your help.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.