|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
下班,占个位,回来帮你弄- Sub cht()
- Dim objFSO As Object, objFile As Objectg
- Dim txtpath As String, cr As Long, ct As String, d As String, allt
- txtpath = ThisWorkbook.Path & "\text.txt" '该为你自己的路径
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.OpenTextFile(txtpath, 1)
- d = objFile.ReadAll
- allt = Split(d, vbCrLf, -1, 1)
- objFile.Close
- cr = InputBox("输入需要更改的文本行数")
- ct = InputBox("输入需要更改的文本内容")
- allt(cr - 1) = ct
- Set objFile = objFSO.createtextfile(txtpath, 1)
- d = Join(allt, vbCrLf)
- objFile.write d
- objFile.Close
- Set objFile = Nothing: Set objFSO = Nothing
- End Sub
复制代码
[ 本帖最后由 赵国辉 于 2009-11-2 12:44 编辑 ] |
|