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.
Thread starter Similar threads Forum Replies Date
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox New Slipstick.com Articles 0
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
J calendar: populate multiple appointment subject fields at once Using Outlook 4
D Reply to a sender does not populate the To: Field Using Outlook 1
K Quickest way to populate email via IMAP up to a server. Using Outlook 1
M Exchange and IMAP Accounts: Populate Exchange Calendar with IMAP Meeting Requests Using Outlook 1
L Can't populate History of Business Contacts- receive 1st error: cannon load an object because it is not available, then 2nd: Cannot display this view Using Outlook 1
A Uploaded Outlook Contacts Will Not Populate Email Address Using Outlook 2
9 BCM 2010 populate created/due field for created Direct Mail Print Using Outlook 4
C Outlook address book won't populate Using Outlook 2
I Get right account to populate on new e-mail (2010) Using Outlook 1
N Activities Tab does not populate with all linked activity 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
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
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















































Top