Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing a txt file to a ComboBox itens

Please, i need import the data txt file to a combobox list itens

How i do it

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing a txt file to a ComboBox itens

Loop through the file and use additem to add to the combobox.

there are several ways to access the textfile

Use File=Open to bring it in as a separate workbook

in Excel 2000 and later, you can import it into an existing worksheet.

You can use low level fileio to read the file.

Post back in this thread with specific followup questions.

--
Regards,
Tom Ogilvy

"mhferreira " wrote in message
...
Please, i need import the data txt file to a combobox list itens

How i do it?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Importing a txt file to a ComboBox itens

Try some code like the following:

Dim FName As String
Dim FNum As String
Dim S As String

FName = "H:\test.txt" '<<<< CHANGE FILE NAME
FNum = FreeFile
Open FName For Input As #FNum
Do
Input #FNum, S
Userform1.ComboBox1.AddItem S
Loop Until EOF(FNum)
Close #FNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"mhferreira " wrote
in message ...
Please, i need import the data txt file to a combobox list

itens

How i do it?


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Importing a txt file to a ComboBox itens

The following is better, as it will properly handle an empty
input file:

Dim FName As String
Dim FNum As String
Dim S As String

FName = "H:\test.txt" '<<< CHANGE FILE NAME
FNum = FreeFile
Open FName For Input As #FNum
Do Until EOF(FNum)
Input #FNum, S
Me.ComboBox1.AddItem S
Loop
Close #FNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Chip Pearson" wrote in message
...
Try some code like the following:

Dim FName As String
Dim FNum As String
Dim S As String

FName = "H:\test.txt" '<<<< CHANGE FILE NAME
FNum = FreeFile
Open FName For Input As #FNum
Do
Input #FNum, S
Userform1.ComboBox1.AddItem S
Loop Until EOF(FNum)
Close #FNum


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"mhferreira " wrote
in message ...
Please, i need import the data txt file to a combobox list

itens

How i do it?


---
Message posted from http://www.ExcelForum.com/





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing text file, only option to edit existing file smokey99 Excel Discussion (Misc queries) 8 April 26th 06 09:08 PM
importing file cindy Excel Discussion (Misc queries) 1 January 17th 06 02:50 PM
reading from another file and pasting to current file, "combobox" Darius New Users to Excel 1 September 26th 05 07:13 AM
need help getting combobox to open a file neowok Excel Programming 2 February 9th 04 06:17 PM
Combobox Change Event when file is saved as E.Anderegg Excel Programming 1 October 1st 03 05:03 PM


All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"