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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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