Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel screen capture to capture cells and row and column headings | Excel Discussion (Misc queries) | |||
Need code to save file to new folder, erase from old folder | Excel Discussion (Misc queries) | |||
open file from folder save in new folder | Excel Programming | |||
Create Folder and Text File in folder | Excel Programming | |||
VBA capture File SaveAs Event | Excel Programming |