CiaronJohn
New Member
- Joined
- Oct 13, 2016
- Messages
- 5
Hi Everyone,
I am new here in this forum, and also in VBA Macro Programming. I am not familiar in Macro Programming. I was told to convert our tool to run from Excel 2003 to Excel 2010, so when I used the tool on Excel 2010 I encountered errors in Application.FileSearch because as I read other forums that specific code was not compatible on Excel 2007 and later. So can anyone please help me convert this codes so that it will run on Excel 2010. Thanks in advance.
Function GetFilename(ByVal path As String, ByVal wavename as String) As String
Dim searchstring As String
searchstring = "*" & wavename & "_0_0*.csv"
GetFilename = '"
Dim f As Variant, buf As String, cnt As Long, FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
With Application.FileSearch
.NewSaerch
.filename = searchstring
.LookIn = path
.SearchSubFolders = False
cnt = Execute()
If cnt = 1 Then
For Each f In .FoundFIles
GetFileName = FSO.GetFile(f).Name
Exit For
End If
End With
Set FSO = Nothing
End Function
I am new here in this forum, and also in VBA Macro Programming. I am not familiar in Macro Programming. I was told to convert our tool to run from Excel 2003 to Excel 2010, so when I used the tool on Excel 2010 I encountered errors in Application.FileSearch because as I read other forums that specific code was not compatible on Excel 2007 and later. So can anyone please help me convert this codes so that it will run on Excel 2010. Thanks in advance.
Function GetFilename(ByVal path As String, ByVal wavename as String) As String
Dim searchstring As String
searchstring = "*" & wavename & "_0_0*.csv"
GetFilename = '"
Dim f As Variant, buf As String, cnt As Long, FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
With Application.FileSearch
.NewSaerch
.filename = searchstring
.LookIn = path
.SearchSubFolders = False
cnt = Execute()
If cnt = 1 Then
For Each f In .FoundFIles
GetFileName = FSO.GetFile(f).Name
Exit For
End If
End With
Set FSO = Nothing
End Function