Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM
VBA capture File SaveAs Event Linda Mcfarlane Excel Programming 2 September 17th 03 04:06 AM


All times are GMT +1. The time now is 06:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"