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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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