Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming wild card file 1

Status
Not open for further replies.

SeaRay

Technical User
Jan 8, 2002
20
US
I download files from my PC based cash register into an access application that I have developed everyday. The files are delimeted and have an extension that access does not recognise (.001). So I rename the file with a .txt extension. However, the files change names slightly eveyday. A file named Crday_25.001 will be named Crday_26.001 the next day. The name before the underscore as well as the extension remain constant. I am trying to refer to the changing part of the file name as a "wild card". I have tried the code below, but keep getting an error that says "can't find file" and high lites the last line. What am I doing wrong?

Private Sub Command1_Click()

Dim strFileName As String
strFileName = Dir$("C:\~Master Files\SSM\001\Crday_*.001")
If strFileName <> &quot;&quot; Then

Name &quot;C:\~Master Files\SSM\&quot; & strFileName As &quot;C:\~Master _ Files\SSM\&quot; & &quot;Credit.txt&quot;

End If

End Sub

I have also tried

Dim strFileName As String
strFileName = Dir$(&quot;C:\~Master Files\SSM\001\Crday_*.001&quot;)
If strFileName <> &quot;&quot; Then
Name strFileName As &quot;Credit.txt&quot;
End If
 
Try:
strFileName = Dir$(&quot;C:\~Master Files\SSM\001\Crday_&quot;+*+&quot;.001&quot;)

The * is a char here.
 
Private Sub Command1_Click()

Dim strFileName As String
strFileName = Dir$(&quot;C:\~Master Files\SSM\001\Crday_*.001&quot;)
If strFileName <> &quot;&quot; Then

Name &quot;C:\~Master Files\SSM\001\&quot; & strFileName As &quot;C:\~Master _ Files\SSM\001\&quot; & &quot;Credit.txt&quot;

End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top