+ Reply to Thread
Results 1 to 3 of 3

Fill a combobox on a form from a txt file

  1. #1
    Daniel Bonallack
    Guest

    Fill a combobox on a form from a txt file

    Can I open a notepad txt file that contains only a list of names, and use
    that to fill a combobox on a form?

    Failing that, can populate the combobox from an Excel file, without having
    to open the Excel file?

    Thanks in advance
    Daniel

  2. #2
    Tom Ogilvy
    Guest

    Re: Fill a combobox on a form from a txt file

    Sub ReadStraightTextFile()
    Dim sStr as String
    Dim LineofText As String

    Open "C:\FILEIO\TEXTFILE.TXT" For Input As #1
    sStr = ""
    Do While Not EOF(1)
    Line Input #1, LineofText
    userform1.combobox1.AddItem LineofText
    Loop
    'Close the file
    Close #1
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Daniel Bonallack" <DanielBonallack@discussions.microsoft.com> wrote in
    message news:40140E7E-E3F7-474C-A5D2-BEC5E47F66ED@microsoft.com...
    > Can I open a notepad txt file that contains only a list of names, and use
    > that to fill a combobox on a form?
    >
    > Failing that, can populate the combobox from an Excel file, without having
    > to open the Excel file?
    >
    > Thanks in advance
    > Daniel




  3. #3
    Daniel Bonallack
    Guest

    Re: Fill a combobox on a form from a txt file

    Thanks very much Tom.

    If you just happen to have any questions about New Zealand Rugby teams,
    that's about the only way I'll ever by able to reciprocate!

    Daniel


    "Tom Ogilvy" wrote:

    > Sub ReadStraightTextFile()
    > Dim sStr as String
    > Dim LineofText As String
    >
    > Open "C:\FILEIO\TEXTFILE.TXT" For Input As #1
    > sStr = ""
    > Do While Not EOF(1)
    > Line Input #1, LineofText
    > userform1.combobox1.AddItem LineofText
    > Loop
    > 'Close the file
    > Close #1
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Daniel Bonallack" <DanielBonallack@discussions.microsoft.com> wrote in
    > message news:40140E7E-E3F7-474C-A5D2-BEC5E47F66ED@microsoft.com...
    > > Can I open a notepad txt file that contains only a list of names, and use
    > > that to fill a combobox on a form?
    > >
    > > Failing that, can populate the combobox from an Excel file, without having
    > > to open the Excel file?
    > >
    > > Thanks in advance
    > > Daniel

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1