错误写入文件vba

我正在尝试使用VBA编写一个文件。 我的代码如下。 它第一次工作,但是当我closuresExcel文件(.xlsm),并尝试再次使用它,它不起作用。

运行macros时没有出现任何错误,但新文件没有出现

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 

对不起大家。 那是愚蠢的。 默认的相对path在User /%MyUser%/ Documents中。

我需要使用ChDir然后打开/写入/closures文件。

  Chdir(ActiveWorkbook.Path)