Ask Experts Questions for FREE Help!
Ask    ||    Answer
 
Advanced  
 

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Compiled Languages > Visual Basic   »   Listbox Strings to word

 
Thread Tools Search this Thread Display Modes
Question
 
 
#1  
Old Sep 7, 2009, 09:51 AM
esperanto234
New Member
esperanto234 is offline
 
Join Date: Sep 2009
Posts: 4
esperanto234 See this member's comment history on his/her Profile page.
Listbox Strings to word

Hi, Im using alistbox to insert names in a word document, im' using the following code but it only inserts the first ITEM on the list.


Code:
Dim strList1 As String
strList1 = ListBox1.List(ListBox1.ListIndex)
ActiveDocument.Bookmarks("p91").Range.Text = strList1

My question is: How can i do to insert ALL items in the listbox in word. I need them to be separated by comas and the last one by "and". Ex:

ITEM1, ITEM2, ITEM3 and ITEM4.

ITEM1, ITEM2 and ITEM3.

ITEM1, ITEM2 and ITEM5.


Of course, if theres only 1 item i need the "and" to be deleted. Ex:

ITEM1

THANK YOU VERY VEERY MUCH!!

Reply With Quote
 
     

Answers
 
 
Old Sep 7, 2009, 10:14 AM   #2  
Computer Expert and Renaissance Man
ScottGem is offline
 
ScottGem's Avatar
 
Join Date: Jan 2003
Location: LI, NY - USA
Posts: 33,652
ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.
Pay to call ScottGem for advice ($.75/min)
Call ScottGem via Skype™
If you are using a multi-select listbox, then you need to loop through the ItemsSelected collection. when the multi-select property is set to yes, the control itself does not store a value.
  Reply With Quote
 
     
 
 
Old Sep 7, 2009, 11:15 AM   #3  
New Member
esperanto234 is offline
 
Join Date: Sep 2009
Posts: 4
esperanto234 See this member's comment history on his/her Profile page.
Quote:
Originally Posted by ScottGem View Post
If you are using a multi-select listbox, then you need to loop through the ItemsSelected collection. when the multi-select property is set to yes, the control itself does not store a value.
Could you please help me with the entire code? I'm using a multi-select listbox.
  Reply With Quote
 
     
 
 
Old Sep 7, 2009, 11:23 AM   #4  
Computer Expert and Renaissance Man
ScottGem is offline
 
ScottGem's Avatar
 
Join Date: Jan 2003
Location: LI, NY - USA
Posts: 33,652
ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.ScottGem See this member's comment history on his/her Profile page.
Pay to call ScottGem for advice ($.75/min)
Call ScottGem via Skype™
I don't know the exact code for VB. I can give you an example for Access VBA, but I don't know if that will help. Try googling VB Multi-Select listbox.
  Reply With Quote
 
     
 
 
Old Sep 7, 2009, 11:29 AM   #5  
New Member
esperanto234 is offline
 
Join Date: Sep 2009
Posts: 4
esperanto234 See this member's comment history on his/her Profile page.
Quote:
Originally Posted by ScottGem View Post
I don't know the exact code for VB. I can give you an example for Access VBA, but I don't know if that will help. Try googling VB Multi-Select listbox.
Thanks anyway for your help.
  Reply With Quote
 
     

Your Answer
Email me when someone replies to my answer
Join Login





Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

 
Similar Sponsors


Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page

Similar Threads
Add a time from a TextBox into a ListBox
(11 replies)
ListBox and Textbox in VB.NET 2008!
(4 replies)
Listbox and textbox in vb.net
(3 replies)
ListBox problem
(1 replies)
get arraylist fields in listbox
(0 replies)

Search this Thread

Advanced Search

Bookmarks

Sponsors



Copyright ©2003 - 2009, Ask Me Help Desk.
All times are GMT -8. The time now is 03:09 AM.