Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2013, 12:29 PM
gvibe@hotmail.com gvibe@hotmail.com is offline Multi-select listbox help Windows XP Multi-select listbox help Office 2007
Novice
Multi-select listbox help
 
Join Date: Jul 2013
Posts: 4
gvibe@hotmail.com is on a distinguished road
Default Multi-select listbox help

I am working on a listbox that pulls information from a table in another word document. Currently, the connection between the parent document listbox and the tabe is working (the listbox populates properly), and the document variables are populated correctly. In short it's working fine with the listbox set to accept single selections.



What I'd like to have is the first listbox open to multiple selections, however, I'm having trouble with the code to transfer multiselections to the variables in the document upon execution of the OK command button. I assume I need some sort of a loop to do this. The table has only two columns and a variable number of rows.

I am adapting code found in a FAQ by Greg Maxey which has been very helpful (Thanks Greg).

Here's the code for the OK button:

Code:
 
Private Sub CommandButton1_Click() 'Continue button
Set oTarget = ActiveDocument
Set oVars = oTarget.Variables
'Ensure that selections have been made and if not warn the user.
If Me.ListBox1.ListIndex = -1 Or Me.ListBox2.ListIndex = -1 Then
    MsgBox "Selections incomplete!"
    Exit Sub
End If
'Insert code that detects multiple selections and transfers output to variables
 
'Add the values of the list boxes to the variables
oVars("Citation").Value = Me.ListBox1.Column(0)
oVars("Violation").Value = Me.ListBox1.Column(1)
oVars("User").Value = Me.ListBox2.Column(0)
oVars("Title").Value = Me.ListBox2.Column(1)
oTarget.Fields.Update
'Update the fields in the document, to display the new content of the docvariable fields.
Unload Me
End Sub
Thanks!
Reply With Quote
  #2  
Old 07-19-2013, 10:54 AM
gvibe@hotmail.com gvibe@hotmail.com is offline Multi-select listbox help Windows XP Multi-select listbox help Office 2007
Novice
Multi-select listbox help
 
Join Date: Jul 2013
Posts: 4
gvibe@hotmail.com is on a distinguished road
Default Still need help

Perhaps my original post was unclear. I am a novice at VBA and need help with a bit of code to pass selected items from a multi-select listbox to a document. The selected items have the following format, and they need to appear in this format in the output document. The source document has a table with the information in two columns (one for the citation and one for the text), and the target document uses variables as insertion points.

H&SC 17920.3(A)(1)
EMC 150.162 (A)(1) Lack of, or improper water closet, lavatory, bathtub or shower in a dwelling or lodging house.

H&SC 17920.3(A)(2)
EMC 150.162 (A)(2) Lack of, or improper water closets, lavatories and bathtubs or showers per number of guests in hotel.

H&SC 17920.3(A)(3)
EMC 150.162 (A)(3) Lack of, or improper kitchen sink in a dwelling unit.


The listbox works fine, I just need help with the output. From what I've read, I'm looking for a loop that transfers the selected items to the target document, but I'm unclear on how to accomplish this. Am I looking to transfer the slected items to an array and then populate the variable with the array, or is there some other way to transfer multple selections to a single variable?

Any help is great appreciated.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
as the return value of another column, using Listbox? marreco Excel Programming 1 03-27-2012 12:48 PM
Multi Line Cell DrDOS Excel 2 03-27-2012 01:16 AM
Multi-Variable Lookup help ebolton Excel 8 05-05-2011 05:28 AM
Saving for Multi-Users louisxiv PowerPoint 0 01-12-2011 02:10 PM
Multi Line Bookmark streng Word 3 07-13-2009 07:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft