View Full Version : Solved: Load a combobox with data from a .txt
gsdonald
09-26-2005, 01:27 PM
Hi all,
I don't suppose anyone knows whether a combobox could "Load" (using AddItem) the data from a .txt file.
The combobox is residing in a PowerPoint file. I'd like it to "upload" the data from a .txt file that I create on a weekly basis.
Any ideas are appreciated.
Thanks,
GSD
Bilby
09-26-2005, 03:44 PM
hi GSD
I have an application (in Word) that loads a box from an INI file. The structure will be different but in my app I read the values into an array and then additem thus;
The way I see it you will need to pre-process your text file into some combobox friendly form.
For iSection = 1 To UBound(arrNumbers)
lstNumbers.AddItem UCase(arrNumbers(iSection))
Next iSection
geekgirlau
09-26-2005, 07:14 PM
Provided your text file doesn't require any manipulation, you could try something like the following:
Dim strTextFile As String
Dim strLine As String
strTextFile = "C:\Test\MyTextFile.txt"
Open strTextFile For Input As #1
Do Until EOF(1)
Input #2, strLine
lstNumbers.AddItem strLine
Loop
sheeeng
09-26-2005, 10:39 PM
Provided your text file doesn't require any manipulation, you could try something like the following:
Dim strTextFile As String
Dim strLine As String
strTextFile = "C:\Test\MyTextFile.txt"
Open strTextFile For Input As #1
Do Until EOF(1)
Input #2, strLine
lstNumbers.AddItem strLine
Loop
Nice code. :thumb Learn a point here.
gsdonald
09-27-2005, 12:39 AM
Hi all and thanks.
I did have to change the
Input #2, strLine
to
Input #1, strLine
But it's up and working!
Another mystery solved. Thanks again to everyone that contributed.
GSD
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.