Pulling a list of Microsoft file filenames into excel

sc9be

New Member
Joined
May 7, 2009
Messages
1
Hi,
I am pretty new to VBA – I am looking to pull various Microsoft office file (word, access, powerpoint, publisher, excel) - filenames into excel cells and maybe even PDF files too.
I wish to select multiple files for example Powerpoint presentations – named “A001-04-11.ppt” and “A002-04-11.ppt” and I wish to pull please these names into cells A1 and A2 respectively showing there file names.
Is there a way I can do this please, I would be most grateful for any help
Sc9be
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi
Paste the following codes in the macro window ( Alt F11) and run the macro. It will pull all word, excel, powerpoint, text, access, pdf files to col A to F
Ravi
Code:
Sub list_files()
Dim a As Long
Dim f As String, b As String
Cells(1, 1) = "=cell(""filename"")"
Cells(1, 2) = "=left(A1,find(""["",A1)-1)"
For a = 1 To 6
b = Choose(a, "*.doc", "*.xls", "*.ppt", "*.txt", "*.pdf", "*.mdb")
Cells(2, a) = b
Cells(3, a).Select
f = Dir(Cells(1, 2) & b)
Do While Len(f) > 0
ActiveCell.Formula = f
ActiveCell.Offset(1, 0).Select
f = Dir()
Loop
Next a
MsgBox "Listing is complete"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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