Find Video Files in Excel or Access with VBA
Question details
Find video files in a folder and its subfolders from Excel or Access without maintaining a list of file extensions.

- Product
- Microsoft Excel 2019 and Microsoft Access 2019
- Device & OS
- Windows 10
- Scenario
- Use VBA to retrieve paths for files that Windows identifies as videos.
- Observed behavior
- The user wants to retrieve video search results for use in Excel or Access rather than only display them in File Explorer.
Check that Windows Search is running and that the target folder is included in the search index. In Windows 10, open Settings > Search > Searching Windows to review indexed locations.
Query Windows Search for video paths with VBA
Use the Windows Search provider to retrieve indexed video paths without maintaining an extension list.
Windows Search exposes indexed properties through its OLE DB provider. This approach queries files classified as videos, but results depend on indexing and Windows' classification; it is not a guaranteed inventory of every video file.
In Excel or Access, press Alt+F11, choose Insert > Module, and paste the macro in the next step.
Paste this code and replace the example folder with the local folder to search, without a trailing backslash: Sub FindIndexedVideos() Dim folder As String, scope As String, sql As String Dim cn As Object, rs As Object folder = "C:\Users\Public\Videos" scope = Replace(Replace(folder, "\", "/"), "'", "''") sql = "SELECT System.ItemPathDisplay FROM SYSTEMINDEX " & _ "WHERE SCOPE = 'file:" & scope & "/' " & _ "AND System.Kind = 'video'" Set cn = CreateObject("ADODB.Connection") cn.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';" Set rs = cn.Execute(sql) Do Until rs.EOF Debug.Print rs.Fields(0).Value rs.MoveNext Loop rs.Close cn.Close End Sub
In the VBA editor, choose View > Immediate Window, place the cursor inside FindIndexedVideos, and press F5. Copy the printed paths into an Excel worksheet or use them in your Access import code.
If expected files are missing, review the folder under Settings > Search > Searching Windows and allow indexing to finish. The SCOPE condition includes indexed subfolders.

Copy video search results from File Explorer
Use this manual option when you need paths but do not need an automated VBA process.
Review Video File Lists in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface for working with file lists and existing Office documents. Paste paths from File Explorer into WPS Spreadsheets; the Windows Search VBA solution itself is specific to Microsoft Office and is not fixed by switching suites.

Frequently Asked Questions
Can VBA directly retrieve File Explorer's video search results?
There is no documented VBA method that returns the results from an open File Explorer search window. You can instead query Windows Search through its provider or maintain your own list of video extensions.
Does the VBA search include subfolders?
Yes. The Windows Search SQL SCOPE condition searches the specified folder and its indexed subfolders.
Why are some video files missing from the results?
The files may not be indexed, or Windows may not classify them as videos. Check Settings > Search > Searching Windows and allow indexing to finish before running the macro again.
Where does the macro put the file paths?
It prints them in the VBA Immediate Window. Open that window with View > Immediate Window or Ctrl+G, then copy the paths or adapt the loop to write them to a worksheet or Access table.




