Posted to microsoft.public.excel.programming
|
|
Open a semi variable name with a macro
Thanx Dave,
This did the trick
Dave Peterson wrote:
If there's only one file like that in the folder:
Option Explicit
Sub testme01()
Dim myFile As String
Dim myPath As String
Dim FoundIt As Boolean
Dim wkbk As Workbook
'change to point at the folder to check
myPath = "c:\my documents\excel"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If
myFile = ""
On Error Resume Next
myFile = Dir(myPath & "*.csv")
On Error GoTo 0
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If
FoundIt = False
Do While myFile < ""
If LCase(myFile) Like "*cgcflh.csv" Then
FoundIt = True
Exit Do
End If
myFile = Dir()
Loop
If FoundIt = True Then
Set wkbk = Workbooks.Open(Filename:=myPath & myFile)
End If
End Sub
That is what i'm doing now, but users can make mistakes so i want to put in
in the macro.
[quoted text clipped - 11 lines]
--
Don Seegers
--
Don Seegers
Message posted via http://www.officekb.com
|