Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
(Excel 2003)
Thought this would be simple, but I'm having problems. I ultimately want to open an xls file, but first have to get the file name because it changes. So, I need to return the xls file name that begins with a given prefix from a certain folder. Only one such file will exist in the folder. It always begins with "YTD Stats", but its full name will change several times per year. It may be "YTD Stats June - RevA" and then the next week change to "YTD Stats June - RevB". Plus the month string can change. So, the only constants are the path, it's an XLS file, and it begins with "YTD Stats". The code below reflects the task and works fine when the path is a normal Windows type folder and drive. But it fails when I use an HTTP path. (Users DO have access permission to the path and successfully open files using the path in code.) So, can the code below be modified to work with an http path? If not, what are some other suggestions to find the xls file name based on a prefix and using an http path? (If I can't make this work programmatically, I'll have to make the user input it, which will be a real hassle for them being it changes without warning. I'm really hoping someone knows of a solution.) Thank you for helping, Daisy Sub GetWkbkName() 'Find the workbook name within a folder that matches a given prefix. Dim strPath As String, strPrefix As String strPath = "http://mycompany.com/firewall/tsp/shared%20documents" strPrefix = "YTD Stats" Dim rw As Long, i As Long With Application.FileSearch .NewSearch .LookIn = strPath .SearchSubFolders = False .Filename = strPrefix & "*.xls" .FileType = msoFileTypeExcelWorkbooks If .Execute() 0 Then For i = 1 To .FoundFiles.Count Range("a1").Value = Dir(.FoundFiles(i)) Exit For Next i Else MsgBox "Error - No stat files found." End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo | Excel Discussion (Misc queries) | |||
Saving txt file from excel by specifying path - drop down directory explorer | Excel Programming | |||
How to ascertain path of file in adjacent directory hierarchy | Excel Programming | |||
How do I insert the directory path in my Excel file? | Excel Worksheet Functions | |||
get path - save new file - same sub-directory as existing file | Excel Programming |