在excel VBA宏中编辑后关闭文本文件 [英] Close text file after editing in excel VBA macro
本文介绍了在excel VBA宏中编辑后关闭文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有这个文本文件,我需要编辑。
编辑必须在一行完成时间。
我想知道如何在编辑后保存并关闭文本文件!!
谢谢...
我尝试了什么:
Hi All,
I have this text file which I need to edit.
Edit has to be done one line at a time.
I was wondering how to save and close the text file after editing!!
Thanks...
What I have tried:
Public Sub edit_sub()
Dim myFile As String
Dim opFile As Integer
myFile = "fileLocation"
opFile = FreeFile
Open myFile For Input As opFile
Do Until EOF(opFile)
Line Input #opFile, txtline
Debug.Print txtline
'check some condition and then edit
'replace the value
Loop
Close opFile
End Sub
在哪里放置保存文本文件的代码?
Where to put the code to save the text file?
推荐答案
从这里开始: Open Statement [ ^ ]然后阅读:从2007 Office system中的宏内写入文本文件 [ ^ ]
Start here: Open Statement[^] then read this: Writing to a Text File from within a Macro in the 2007 Office System[^]
这篇关于在excel VBA宏中编辑后关闭文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文