Option Explicit
'点击一次按钮,生成一个符合条件的文件
Private Sub Command1_Click()
Dim y As Long
Dim m As Long
Dim d As Long
y = Year(Date)
m = Month(Date)
d = Day(Date)
Dim s As String
s = "AB" + Right(CStr(y), 1) + Right("0" + CStr(m), 2) + Right("0" + CStr(d), 2)
'下面假设文件要保存在c:\test下
Dim dic As String
dic = "c:\test\"
Dim path As String
Dim i As Long
For i = 0 To 9
path = dic + s + CStr(i) + ".txt"
If Dir(path, vbDirectory) = "" Then
Open path For Binary As #1
Close #1
MsgBox "本次保存的文件名为:" + path
Exit For
End If
Next
End Sub