0
我想使用VBA编写文件。我的代码如下。它第一次工作,但当我关闭Excel文件(.xlsm)并尝试再次使用它时,它不起作用。错误写入文件vba
运行宏,但新的文件没有出现
Sub LogInformation(LogMessage As String)
Const LogFileName As String = "TEXTFILE.db"
Dim FileNum As Integer
FileNum = FreeFile ' next file number
Open LogFileName For Append As #FileNum ' creates the file if it doesn't exist
Print #FileNum, LogMessage ' write information at the end of the text file
Close #FileNum ' close the file
End Sub
是否因为'FileNum = FreeFile'总是找到'Next'文件号? – user959631 2011-12-23 21:30:58
It aways returns 1 – Makah 2011-12-23 21:32:42
Ohh好吧,我真的不知道VBA很多,抱歉Ohh刚刚意识到,它只在文件不存在时才创建文件。也许这就是问题所在? – user959631 2011-12-23 21:34:34