Multi-column Listbox reload data into Userform

L

LittleAnn

Hi

I have 5 multi-column listboxes on my Template, which enter the abbreviation
of the word that is selected on each listbox into my document rather then the
word itself.

I set up a button so that the user could recall the userform in order to
edit any mistakes they initially inputted into the form, which works fine,
all the information returns to the Userform i.e. all text boxes, listboxes,
combo box.

My problem is that once the document is saved and closed, when the user
opens the document again and wants to make further changes and presses the
recall userform button, all the information that was entered initially goes
back into the form except for the listbox entries.

I have tried a few different codes but still nothing works. Any Help would
greatly be appreciated. I have posted what I have so far on the code below.
thanking you in advance.

In the Userform Option Explicit section I have for the list box entries and
combo box as follows:

Private Sub Userform_Initialize()
Dim myArray1 As Variant
Dim myArray2 As Variant
Dim myArray3 As Variant
Dim myArray4 As Variant
Dim myArray5 As Variant
Dim myArray6 As Variant
Dim myArray7 As Variant
Dim myArray8 As Variant
Dim myArray9 As Variant
Dim myArray10 As Variant
Dim i As Long
Dim j As Long
Dim k As Long
Dim l As Long
Dim m As Long
myArray1 = Split("Select Identifier|AdeH|EBT|" & "Rail|Rail Procurement",
"|")
myArray2 = Split(" |AH|ES|IE|RP", "|")
With Me.Identifier
.ColumnWidths = "60;0"
For i = 0 To UBound(myArray1)
.AddItem
.List(i, 0) = myArray1(i)
.List(i, 1) = myArray2(i)
Next i
End With
myArray3 = Split("Select Team|Architecture|Assurance|" & "Civil and
Structural Engineering|Construction Planning|Cost Management", "|")
myArray4 = Split(" |ARC|ASS|" & "CAS|CPL|COS|" , "|")
With Me.Team
.ColumnWidths = "60;0"
For j = 0 To UBound(myArray3)
.AddItem
.List(j, 0) = myArray3(j)
.List(j, 1) = myArray4(j)
Next j
End With
myArray5 = Split("Select Zone|Central|Station|Dock Station|Tie-In|" , "|")
myArray6 = Split("|CE|CS|DS|ET|", "|")
With Me.Zone
.ColumnWidths = "60;0"
For k = 0 To UBound(myArray5)
.AddItem
.List(k, 0) = myArray5(k)
.List(k, 1) = myArray6(k)
Next k
End With
myArray7 = Split("Select Document Type|Agenda|Design
Calculation|Correspondence|Capital Cost Plan|" , "|")
myArray8 = Split("|AGN|CAL|COR|COS|", "|")
With Me.DocumentType
.ColumnWidths = "60;0"
For l = 0 To UBound(myArray7)
.AddItem
.List(l, 0) = myArray7(l)
.List(l, 1) = myArray8(l)
Next l
End With
Me.IssueSTATUS.Style = fmStyleDropDownList
Me.IssueSTATUS.BoundColumn = 0
With Me
.IssueSTATUS.AddItem "Select Status"
.IssueSTATUS.AddItem "Draft"
.IssueSTATUS.AddItem "Issue for Review"
.IssueSTATUS.AddItem "Issue for Approval"
.IssueSTATUS.AddItem "Issue for Information"
.IssueSTATUS.AddItem "FINAL"

End With
Me.IssueSTATUS.ListIndex = 0

End Sub


And for the Displaying of the Userform once recalled by the user I have the
following code (but the listbox entries work fine when the doc is still
opened but once saved, closed and reopened the list box entries do not
re-enter the userform):

Sub DisplayUserForm()
Dim oRng As Word.Range
Dim oBM As Bookmarks
Set oBM = ActiveDocument.Bookmarks
UserForm1.DocumentTitle.Text = oBM("DocumentTitle").Range.Text
UserForm1.Continued.Text = oBM("Continued").Range.Text
UserForm1.Identifier.List(i, 1) = oBM("Identifier").Range.Text
UserForm1.Team.List(j, 1) = oBM("Team").Range.Text
UserForm1.Zone.List(k, 1) = oBM("Zone").Range.Text
UserForm1.DocumentType.List(l, 1) = oBM("DocumentType").Range.Text
UserForm1.SeqNumber.Text = oBM("SeqNumber").Range.Text
UserForm1.Rev.Text = oBM("Rev").Range.Text
UserForm1.IssueDATE.Text = oBM("IssueDATE").Range.Text
UserForm1.IssueSTATUS.Text = oBM("IssueSTATUS").Range.Text
UserForm1.Show
End Sub


Thanks again for your help
 
D

Doug Robbins - Word MVP

In the following commands from your DisplayForm routine

UserForm1.Identifier.List(i, 1) = oBM("Identifier").Range.Text
UserForm1.Team.List(j, 1) = oBM("Team").Range.Text
UserForm1.Zone.List(k, 1) = oBM("Zone").Range.Text
UserForm1.DocumentType.List(l, 1) = oBM("DocumentType").Range.Text

from where would the routine get the values of i, j, k and l

--
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
 
L

LittleAnn

HI Doug

The reason behind that coding is I was following on from the coding I had
initially put into the Initialise event, as I put in other coding to begin
with in order to try and figure it out for myself but kept getting error
marks and with the below coding it seemed to work ok as was getting no errors
poping up and the results were all going back into the Userform fine, the
only thing is that when people saved and closed the document and then
reopened it to edit information through the DisplayUserform, the list box
selections were empty and it would not recall the entries.
 
D

Doug Robbins - Word MVP

I think that what you need to do is when the user initially makes their
selections, you save the .ListIndex of the selected item from each listbox
to a variable in the document and then when the document is reloaded and the
useform is displayed, the initialize code, after populating the list boxes,
interrogates the values of the document variables and sets the .ListIndex
property of each listbox.

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top