从WORD中读出的内容是看不到回车符的,所以所有内容全部连续显示,但并非是没有回车符,这可能是因为VB6中用的是UNICODE代码的原因,如果要从中挑出一部分行,得首先将其分行。为此我专门为你写了以下程序段,它可以实现将读出来的内容以纯文本文件的形式存放在磁盘上,并按原来在WORD中的行分好。接下来的工作就再从这个文件中读出你要的行就可以了。Private Sub Command1_Click() Dim wdapp As Word.application Set wdapp = CreateObject("Word.Application") 'wordObject.Visible = True 'wordObject.Activate wdapp.Documents.Open FileName:="d:\temp.doc" wdapp.selection.wholestory wtx = wdapp.selection.Text wdapp.Quit Open "d:\abc.txt" For Output As #1 '要写入的文件 Do p = InStr(wtx, Chr(13)) '找回车符的位置 If p = 0 Then Exit Do '找不到就结束 ln = Len(wtx) px = Left(wtx, p - 1) '取出一行 Print #1, px '写入文件 wtx = Right(wtx, ln - p)'将已经取走的部分去掉 Loop Print #1, wtx '将最后一行写入文件 Close End Sub能够对您有所帮助是我最大的快乐!!!欢迎交流!我已经给你发到邮箱里了注意收看
To waq2001(双目佳):快死就好,临死前做件善事,把分儿全散了吧!
Dim wdapp As Word.application
Set wdapp = CreateObject("Word.Application")
'wordObject.Visible = True
'wordObject.Activate
wdapp.Documents.Open FileName:="d:\temp.doc"
wdapp.selection.wholestory
wtx = wdapp.selection.Text
wdapp.Quit
Open "d:\abc.txt" For Output As #1 '要写入的文件
Do
p = InStr(wtx, Chr(13)) '找回车符的位置
If p = 0 Then Exit Do '找不到就结束
ln = Len(wtx)
px = Left(wtx, p - 1) '取出一行
Print #1, px '写入文件
wtx = Right(wtx, ln - p)'将已经取走的部分去掉
Loop
Print #1, wtx '将最后一行写入文件
Close
End Sub能够对您有所帮助是我最大的快乐!!!欢迎交流!我已经给你发到邮箱里了注意收看