![]() |
How to capture file name in a folder?
In a folder exists one .ppt file and a non .ppt file. In vba I want to
capture the name of the ppt file. Can someone tell me the best way to do that? For example, the path is c:\whatever and the ppt name might be anything. I just want the name of the ppt file, not the other file. Thanks. |
How to capture file name in a folder?
Gregg,
Sub FindFile() Dim strPath As String Dim strFile As String strPath = "C:\whatever\*.ppt" strFile = Dir(strPath) MsgBox strFile End Sub Jim Cone San Francisco, USA "Gregg" wrote in message ups.com... In a folder exists one .ppt file and a non .ppt file. In vba I want to capture the name of the ppt file. Can someone tell me the best way to do that? For example, the path is c:\whatever and the ppt name might be anything. I just want the name of the ppt file, not the other file. Thanks. |
How to capture file name in a folder?
Try this --
Sub GetPPT() Dim f as string f = Dir("C:\whatever\*.ppt") End Sub "Gregg" wrote in message ups.com... In a folder exists one .ppt file and a non .ppt file. In vba I want to capture the name of the ppt file. Can someone tell me the best way to do that? For example, the path is c:\whatever and the ppt name might be anything. I just want the name of the ppt file, not the other file. Thanks. |
How to capture file name in a folder?
Thanks, Jim. I did keep trying and had come up with the following, but
I like yours much better. Thanks. Dim sFileNm As String With Application.FileSearch .NewSearch .LookIn = "c:\whatever" .SearchSubFolders = False .FileName = "*.ppt" .Execute sFileNm = Right(.FoundFiles(1), _ (Len(.FoundFiles(1)) - _ InStrRev(.FoundFiles(1), "\"))) End With Jim Cone wrote: Gregg, Sub FindFile() Dim strPath As String Dim strFile As String strPath = "C:\whatever\*.ppt" strFile = Dir(strPath) MsgBox strFile End Sub Jim Cone San Francisco, USA "Gregg" wrote in message ups.com... In a folder exists one .ppt file and a non .ppt file. In vba I want to capture the name of the ppt file. Can someone tell me the best way to do that? For example, the path is c:\whatever and the ppt name might be anything. I just want the name of the ppt file, not the other file. Thanks. |
How to capture file name in a folder?
Thanks, Roy. I went back and read about the DIR function. Nice.
Roy Harrill wrote: Try this -- Sub GetPPT() Dim f as string f = Dir("C:\whatever\*.ppt") End Sub "Gregg" wrote in message ups.com... In a folder exists one .ppt file and a non .ppt file. In vba I want to capture the name of the ppt file. Can someone tell me the best way to do that? For example, the path is c:\whatever and the ppt name might be anything. I just want the name of the ppt file, not the other file. Thanks. |
All times are GMT +1. The time now is 10:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com