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 2007

Tip: Looking for answers? Try searching our database.

Cascading List Boxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gmat - 29 Oct 2007 20:24 GMT
Word 2003 VBA problem regarding Cascading List Boxes:  The sub userform data
will not display in the Word document.  There seems to be some code missing.  
The userform allows you to select from the cascading list boxes, however,
once the command button "OK" is selected to send the entries back to the Word
document, it takes you to the code again and does not display the entries in
the document.

Please help!
Signature

gmat

Doug Robbins - Word MVP - 29 Oct 2007 20:39 GMT
Seems to me that all of the code is missing from your post.  If you show us
what it is, we may be able to help.

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

> Word 2003 VBA problem regarding Cascading List Boxes:  The sub userform
> data
[quoted text clipped - 8 lines]
>
> Please help!
gmat - 29 Oct 2007 20:52 GMT
Thank you for your reply.  Here's the code I have:

Private Sub CommandButton1_Click()
If ListBox1.ListIndex > -1 And ListBox2.ListIndex > -1 And
ListBox3.ListIndex > -1 Then
 If MsgBox("You selected:  " & ListBox1.Text & ";" & "  " _
       & ListBox2.Text & ";" & "  " & ListBox3 _
       & " .  Is this correct?", vbQuestion + vbYesNo, "Selection") = vbYes
Then
   MsgBox "Proceed."
   Me.Hide
 End If
Else
 MsgBox "Please select a Big Idea, Concept and Skill Expectation."
End If
End Sub

Private Sub UserForm_Initialize()
Dim myArray()  As Variant
Dim sourcedoc  As Document
Dim i As Integer
Dim j As Integer
Dim myitem As Range
Dim m As Long
Dim n As Long
Application.ScreenUpdating = False
Set sourcedoc = Documents.Open(FileName:="C:\Lesson Design Tool\Source.doc",
Visible:=False)
i = sourcedoc.Tables(1).Rows.Count - 1
j = sourcedoc.Tables(1).Columns.Count
ListBox1.ColumnWidths = "400;0;0"
ListBox1.ColumnCount = j
ReDim myArray(i, j)
For n = 0 To j - 1
 For m = 0 To i - 1
   Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
   myitem.End = myitem.End - 1
   myArray(m, n) = myitem.Text
 Next m
Next n
ListBox1.List() = myArray
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub

Private Sub ListBox1_Change()
Dim myArray As Variant
myArray = Split(ListBox1.List(ListBox1.ListIndex, 1), Chr(13))
ListBox2.List = myArray
ListBox3.Clear
End Sub

Private Sub ListBox2_Change()
Dim myArray1 As Variant
Dim myArray2 As Variant
myArray1 = Split(ListBox1.List(ListBox1.ListIndex, 2), Chr(13))
myArray2 = Split(myArray1(ListBox2.ListIndex), "|")
ListBox3.List = myArray2
End Sub

Signature

gmat

> Seems to me that all of the code is missing from your post.  If you show us
> what it is, we may be able to help.
[quoted text clipped - 11 lines]
> >
> > Please help!
alborg - 31 Oct 2007 04:00 GMT
Hi gmat:

You need to reference a place to put in your data, s.a. a bookmark. Check
out a possible method-

Private Sub CommandButton1_Click()
Dim strxx as String
If ListBox1.ListIndex > -1 And ListBox2.ListIndex > -1 And
ListBox3.ListIndex > -1 Then
strxx = ListBox1.Text & ";" & "  " & ListBox2.Text & ";" & "  " & ListBox3
 If MsgBox("You selected:  " & xx & " .  Is this correct?", vbQuestion +
vbYesNo, "Selection") = vbYes Then
   MsgBox "Proceed."
   Me.Hide
   Application.ActiveDocument.Bookmarks("mybookmark").Range.Text =
IIf(IsNull(strxx) Or Len(strxx) = 0, " ", strxx)
 End If
Else
 MsgBox "Please select a Big Idea, Concept and Skill Expectation."
End If
End Sub

That should do what you want...

Cheers,
Al

> Thank you for your reply.  Here's the code I have:
>
[quoted text clipped - 70 lines]
> > >
> > > Please help!
gmat - 31 Oct 2007 14:36 GMT
Thank you.  I appreciate your help.

Signature

gmat

> Hi gmat:
>
[quoted text clipped - 97 lines]
> > > >
> > > > Please help!
Doug Robbins - Word MVP - 31 Oct 2007 11:30 GMT
You need something like

Then
   With ActiveDocument
        .Variables("varname").Value = ListBox1.Text & ";" & "  " _
       & ListBox2.Text & ";" & "  " & ListBox3
       .Range.Fields.Update
   End With
   MsgBox "Proceed."
   Me.Hide
Else
   MsgBox "Please select a Big Idea, Concept and Skill Expectation."
End If

You should not have an End If before the Else

Then you would also need a DOCVARIABLE varname field in the template to
display the value that is loaded into the variable.  If you do not want all
of the data that has been selected to appear in the one place like that,
then you need to create separate Document Variables for each individual
piece of the data and have corresponding DOCVARIABLE fields in the template.

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

> Thank you for your reply.  Here's the code I have:
>
[quoted text clipped - 76 lines]
>> >
>> > Please help!
gmat - 31 Oct 2007 14:38 GMT
Thank you again for your help.  It's much appreciated.

Signature

gmat

> You need something like
>
[quoted text clipped - 98 lines]
> >> >
> >> > Please 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.