Populate List Box with Large List 
Author Message
 Populate List Box with Large List

I am looking for a way to put a large, easily edited, list into a list box in
word. Using the Add.Item will not work for this. I can't count on all users
having excel or access. Therefore, an .ini file would work, but I don't know
how to access it.

Anybody have experience or success with such a project? Any help would be
greatly appreciated.

Paul Sweeney



Sun, 02 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List

Hi Paul,

use this as a template for creating your own. You will need to add Microsoft
Scripting Runtime to your project first. the FSO is an extremely fast method
to access text data. This particular example loads approximately 250
agencies into a combo box in a dialog in less than a second. The text
"~Agencies" in my text file identifies the beginning of the list of
Agencies. I also have list of other types in the same file, but used in
other situations. The whole setup is easily maintained in a single text
file.

'   The first part is to get the Agencies names from the file
lcb_globals.txt
    Dim myFSO As FileSystemObject
    Dim theFile As File
    Dim ts As TextStream
    Dim aStr As String
    Dim i As Integer
    Dim doIt As Boolean

    Set myFSO = CreateObject("Scripting.FileSystemObject")
    Set theFile = myFSO.GetFile("C:\lcb_globals.txt")
    Set ts = theFile.OpenAsTextStream(ForReading)

'   Read in the names from the file & add to combobox.
    i = 0
    doIt = False
    Do While ts.AtEndOfStream <> True
        aStr = ts.ReadLine    'reads each line
        If aStr = "~Agencies" Then    'this is the identifier for the
beginning of the agency list
            doIt = True
        ElseIf doIt Then
            If aStr = "" Then    'the end of the list was reached (a blank
line)
                doIt = False
            Else
                If i = 0 Then NewRegDlog.AgencyBox.Value = aStr
                NewRegDlog.AgencyBox.AddItem (aStr)
                i = i + 1
            End If  'empty string
        End If  ' doit true
    Loop

Hope this helps and have a great day.

--
~~~~~~~~~~~~~~~~~~~~~~
Stephen Lang
401 S. Carson Street
Carson City, NV 89703
775.684.6830
GMT-8
slangatlcb state nv us
~~~~~~~~~~~~~~~~~~~~~~
To respond via e-mail:


Quote:
> I am looking for a way to put a large, easily edited, list into a list box
in
> word. Using the Add.Item will not work for this. I can't count on all
users
> having excel or access. Therefore, an .ini file would work, but I don't
know
> how to access it.

> Anybody have experience or success with such a project? Any help would be
> greatly appreciated.

> Paul Sweeney



Sun, 02 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List
Paul,

You can use filesystemobject to open, read, and write to text files.
Why does a user having the programs Excel or Access have to do with
populating a listbox?  Curious.

g-



Quote:
> I am looking for a way to put a large, easily edited, list into a
list box in
> word. Using the Add.Item will not work for this. I can't count on all
users
> having excel or access. Therefore, an .ini file would work, but I
don't know
> how to access it.

> Anybody have experience or success with such a project? Any help
would be
> greatly appreciated.

> Paul Sweeney

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 02 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List
Hi George,

Quote:
> Why does a user having the programs Excel or Access have to do with
> populating a listbox?  Curious.

I guess because Paul doesn't want a solution that involves automating Excel
or Access.

To Paul: The user can retrieve data from an Excel spreadsheet or an Access
database *without* having Excel/Acces installed by using DAO/ADO. There is
an example of doing this with an Excel spreadsheet at:

<http://www.mvps.org/word/FAQs/OfficeInterDev/ExcelToWordWithDAO.htm>

Fellow Word MVP Cindy Meister has an example of doing this with an Access
database on her website:

<http://homepage.swissonline.ch/cindymeister>

--
Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.



Mon, 03 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List
I am under the gun at the moment, but given the responses, I'll post my
code either tonight or tomorrow.

g-



Quote:
> Hi George,

> > Why does a user having the programs Excel or Access have to do with
> > populating a listbox?  Curious.

> I guess because Paul doesn't want a solution that involves automating
Excel
> or Access.

> To Paul: The user can retrieve data from an Excel spreadsheet or an
Access
> database *without* having Excel/Acces installed by using DAO/ADO.
There is
> an example of doing this with an Excel spreadsheet at:

> <http://www.mvps.org/word/FAQs/OfficeInterDev/ExcelToWordWithDAO.htm>

> Fellow Word MVP Cindy Meister has an example of doing this with an
Access
> database on her website:

> <http://homepage.swissonline.ch/cindymeister>

> --
> Hope this helps.
> ibby

> Please post replies or follow-ups to the **newsgroup** so that
participants
> may benefit or contribute.

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 04 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List
Heh, please ignore my previous post.

So crazy, not even posting under the correct topic.

lol

g-


Quote:

> I am under the gun at the moment, but given the responses, I'll post
my
> code either tonight or tomorrow.

> g-



> > Hi George,

> > > Why does a user having the programs Excel or Access have to do
with
> > > populating a listbox?  Curious.

> > I guess because Paul doesn't want a solution that involves
automating
> Excel
> > or Access.

> > To Paul: The user can retrieve data from an Excel spreadsheet or an
> Access
> > database *without* having Excel/Acces installed by using DAO/ADO.
> There is
> > an example of doing this with an Excel spreadsheet at:

<http://www.mvps.org/word/FAQs/OfficeInterDev/ExcelToWordWithDAO.htm>

- Show quoted text -

Quote:

> > Fellow Word MVP Cindy Meister has an example of doing this with an
> Access
> > database on her website:

> > <http://homepage.swissonline.ch/cindymeister>

> > --
> > Hope this helps.
> > ibby

> > Please post replies or follow-ups to the **newsgroup** so that
> participants
> > may benefit or contribute.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 04 Feb 2003 03:00:00 GMT  
 Populate List Box with Large List
Thank everyone for your help!


Sun, 09 Feb 2003 10:50:30 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Populating a List Box with a large list

2. Use list from excel or access to populate combo/list box

3. Beginner: Populating text box by selecting from list box

4. How to list macro names in a combo box or a list box

5. Help wanted with file list boxes and list boxes

6. VB List Box Versus Access List Box

7. Q: List Box to List Box Code

8. List box within List box

9. List box within List box

10. List box within List box

11. Populate list box of networked PC's

12. Populate list box with names of folders on a selected disk

 

 
Powered by phpBB® Forum Software