vba 如何从指定行开始读取文本文件数据

[复制链接]
查看11 | 回复1 | 2011-4-3 06:25:23 | 显示全部楼层 |阅读模式
回复

使用道具 举报

千问 | 2011-4-3 06:25:23 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">Dim fso , sFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0
Const BeginLine = 5 \'指定行,请修改

Set fso = CreateObject(\"Scripting.FileSystemObject\")

Set sFile = fso.OpenTextFile( \"1.txt\", ForReading,TristateFalse) \'打开文本文件,请修改

Do While Not sFile.AtEndOfStream

If sFile.Line = BeginLine Then \'从指定行开始读取文本文件数据

MsgBox sFile.ReadLine

End If

sFile.Skipline

Loop


sFile.Close

Set fso = Nothing

Set sFile = Nothing
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行