VBA - List all Files in Folder - Dir() stops part-way through

i_excel

Board Regular
Joined
Jun 4, 2015
Messages
113
Hey

I've got emails in a desktop folder and I'm trying to list their file names in a worksheet. I've written the below code for that purpose but I'm facing a couple of problems:
1. The filenames are truncated: 20080607-MySpace pa#BFD0E4.html appears rather than 20080607-MySpace password request-36629. I understand this may have something to do with working on a mac, so I don't care so much about resolving this issue.
2. The listing stops part-way through so that i'm only getting about 33,000 instead of 38,000 emails listed. This is a problem.

Any help with the above would be greatly appreciated. Again, I note I'm using a mac.

i_excel


Code:
Sub ListEmails()    
    Dim i As Integer: i = 1
    Dim StrFile As String


    StrFile = Dir("Macintosh HD:Users:Name:Desktop:Gmail Data:test:messages:")  '& filenameCriteria)
    StrFile = Dir()
    
    Do While StrFile <> ""
        Cells(i + 1, 1) = i
        Cells(i + 1, 2).Value = StrFile
        StrFile = Dir()
        
    i = i + 1
    Loop


End Sub
 
I have looked at this several times but have not pressed purchase.....just did it on kindle edition...Once I've recovered from a beating from the wife I'll get into it
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,216,085
Messages
6,128,732
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top