[求助]在vb中从word中导入数据的问题?
我用下面一段代码从word中导入全部数据, 然后添加到textbox中,却无段落之分(整个为一段),我想导入后仍然有段落!
Dim oWord As Object
Set oWord = CreateObject( "Word.Application ")
oWord.documents.Open (sName)
With oWord.activedocument
.Unprotect Password:= "12345 "
text1 = .Range
.Close False
End With
[解决办法]
我是这样解决的,不知道行不行
第一步,将DOC转换成TXT
Function DocToTxt(doc_fn As String, txt_fn As String, Optional Doc_password As String) As Boolean
Dim W As Object
Dim d As Object
Set W = CreateObject( "Word.Application ")
Set d = W.Documents.Open(doc_fn, False, True, False, , , False, , , wdOpenFormatAuto)
If Not IsMissing(Doc_password) Then
d.ActiveDocument.Unprotect password:=Doc_password
End If
d.SaveAs txt_fn, wdFormatText, False, , False, , False, False, False, False, False
d.Close False
Set d = Nothing
W.Quit False
Set W = Nothing
DocToTxt = True
Exit Function
第二步
再读取TXT就行了