Palmer
Palmer

Reputation: 78

How to create VB loop: foreach file with prefix in directory?

I have to use vb for powerpoint macros. I am stuck figuring out how to add a prefix with vb wildcard in the foreach.

I need it to say foreach file in C:/ with prefix "customslide". The slides will be enumerated 0-infinite. Jpg format if it matters. I suspect it will add alphanumerically but if not please advise how to remedy.

Even a link to proper tutorial is appreciated.

Dim fso As New FileSystemObject
Dim fil As File

For Each fil In fso.GetFolder("C:\").Files
  Debug.Print fil.Name
Next

I have code in place for adding slide to my presentation, but only by specific filename so for example print file name is in place.

Upvotes: 0

Views: 220

Answers (1)

one angry researcher
one angry researcher

Reputation: 612

For Each fil In fso.GetFolder("C:\*customslide*").Files
  Debug.Print fil.Name
Next

Upvotes: 2

Related Questions