Populate Listbox from Txt File

Status
Not open for further replies.

Alan McGowan

Senior Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
I have a text file that is in the following format (8 values per line)

txt1,txt2,txt3 etc
txt4,txt5,txt6 etc
txt7,txt8,txt9 etc

I am trying to populate a listbox with this information but I'm having no success. I was trying to use code similar to the following but keep getting a runtime error. I changed the column count to 8 and expanded the code under the .Additem

Code:
Dim fn As String, ff As Integer, txt As String
    fn = "d:\filemail\folders.txt" '< --- .txt file path
    txt = Space(FileLen(fn))
    ff = FreeFile
    Open fn For Binary As #ff
    Get #ff, , txt
    Close #ff


Dim myArray() As String
Dim j As Integer
  myArray = Split(txt, vbCrLf)
    'Use .List method to populate listbox.
    With ListBox1
        .ColumnCount = 2
        For j = 0 To UBound(myArray)
            .AddItem
            .List(j, 0) = Split(myArray(j), ",")(0)
            .List(j, 1) = Split(myArray(j), ",")(1)
        Next j
       
    End With

Any thoughts?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox Using Outlook 0
C Populate form data into message body Outlook VBA and Custom Forms 1
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
D Cannot populate certain UserProperties in Outlook from Excel Outlook VBA and Custom Forms 2
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
A Populate Textbox from Txt File Outlook VBA and Custom Forms 1
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
T populate calendar with appointments and send reminders Using Outlook 1
A Populate Excel from Outlook Userform Outlook VBA and Custom Forms 3
J Live Meeting Location populate from body Outlook VBA and Custom Forms 4
A How can I populate a dropdown list? BCM (Business Contact Manager) 4
rohit I want to Populate Popup box while sending any email with attachment. Outlook VBA and Custom Forms 4
rohit I want to Populate Popup box while sending any email with attachment Using Outlook 1
A Cannot populate IMAP folders Using Outlook 1
S Pre populate subject + body + attachment to already open email in outlook 2007 Using Outlook 2
S Populate textbox values from one form to another form. Using Outlook 0
B Auto Populate From Field Using Outlook 3
G Populate an Outlook 2007 template with spreadsheet data. Outlook VBA and Custom Forms 1
R Populate Form with appointments from Calendar Outlook VBA and Custom Forms 1
J populate word template from Outlook custom form Outlook VBA and Custom Forms 2
G Populate BCC field with all Contacts within a Contact Folder Outlook VBA and Custom Forms 4
M Create new Contacts folder and populate it from Access Outlook VBA and Custom Forms 1
A Macro - Open new message, populate from and subject fields, and message text Outlook VBA and Custom Forms 1
G Macro: Create New Message and Auto populate To Field Outlook VBA and Custom Forms 5
S populate body with Word data Outlook VBA and Custom Forms 7
L how to populate multiple users contacts Outlook VBA and Custom Forms 9
A Populate task field based on value of other field Outlook VBA and Custom Forms 9
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
O VBA Cases with Listbox - Can you use Multi-Select? Outlook VBA and Custom Forms 4
A Multi-select Listbox Outlook VBA and Custom Forms 6
K Selecting a folder from an entry in a Listbox Outlook VBA and Custom Forms 1
D populating listbox on custom form from Access Outlook VBA and Custom Forms 7
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
F Adding textbox filter to listbox? Outlook VBA and Custom Forms 2
T Populating listbox with MS Access table Using Outlook 2
G Colors in Listbox Outlook VBA and Custom Forms 2
T Listbox bound Outlook VBA and Custom Forms 6
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
T Outlook converts sent email to txt attachments when sync Using Outlook 0
N Paste content to Excel when .txt file (attachment) is opened Outlook VBA and Custom Forms 1
B Outlook 2000 Rule to Move txt msg Not Working if size >24KB Using Outlook 3
T Help! Internally sent emailed Documents changing to notepad .txt Using Outlook 3

Similar threads

Back
Top