PDA

View Full Version : Sleeper: Problem with changing filenames



Big Gill
09-14-2005, 03:32 AM
Hi All.......
Hoping someone can help me with my problem??!!

I have this file which i receive every week with the same file name but different number on the end of it

And in order to run my macros on it i have to change my code everyweek !

Is there anything i can do in VB to make my macro pick up the file name every week, without me having to change it????

Thanks ppl...........:banghead:

Bob Phillips
09-14-2005, 03:42 AM
Look at the GetOpenFilename method in VBA help, it allows you to browse for the file.

gibbo1715
09-14-2005, 04:26 AM
This might interest you




Option Explicit

Function GetFolderPath() As String
Dim oShell As Object
Set oShell = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please select folder", 0, "c:\\")'Change C:\\ to your path[VBA
If Not oShell Is Nothing Then
GetFolderPath = oShell.Items.Item.Path
Else
GetFolderPath = vbNullString
End If
Set oShell = Nothing
End Function

Sub Test()
Dim FName As String
FName = GetFolderPath
msgBox FName
End Sub