Sub AddFirstLine() Dim filePath As String Dim fileNum As Integer Dim fileContent As String Dim newFileContent As String

'设置文件路径
filePath = "C:\test.txt"

'打开文件
fileNum = FreeFile()
Open filePath For Input As fileNum
fileContent = Input(LOF(fileNum), fileNum)
Close fileNum

'在文件内容前面添加新的一行
newFileContent = "规避" & vbNewLine & fileContent

'重新打开文件并写入新的内容
fileNum = FreeFile()
Open filePath For Output As fileNum
Print #fileNum, newFileContent
Close fileNum

End Sub


原文地址: https://www.cveoy.top/t/topic/b34X 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录