以下代码段抛出错误 52 - 错误的文件名或编号,我不知道为什么:
Private Sub InitializeLogFile()
Dim fileNumber As Integer
filename = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".", -1, vbTextCompare) - 1))
LOG_FULL_FILENAME = "D:\data\" & Environ("USERNAME") & "\My Documents\" + filename + "_" + Format(Now, "yyyymmdd_hh:mm:ss") + ".log"
MsgBox LOG_FULL_FILENAME
fileNumber = FreeFile
MsgBox fileNumber
Open LOG_FULL_FILENAME For Append As #fileNumber
Print #fileNumber, Date & " - " & ThisWorkbook.Name & " opened. "
Print #fileNumber,
Close #fileNumber
End Sub
有人可以指出我的错误吗?