- 帖子
- 231
- 主題
- 55
- 精華
- 0
- 積分
- 293
- 點名
- 0
- 作業系統
- winxp
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 來自
- KEELUNG
- 註冊時間
- 2010-7-24
- 最後登錄
- 2018-8-28
|
各位大大好:
小弟想利用下列語法取出指定WORD檔
其檔案格式為RTF。但發現該檔案資料取
出之後其位置已位移,因此無法像TXT檔
可計算第幾位元數。
小弟開啟WORD也發現它有使用到定位點
,從其標題有五個部分也分別使用定位點。
但只要讀取該資料時,又會出現整列資料
併在一起。無法像它使用的定位點可分開讀取。
請問如何可算出位元數並取出該檔案
資料轉入至EXCEL表內呢?
語法如下:
Sub test()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim tString As String, tRange As Word.Range
Dim p As Long
Dim mFile$
Application.ScreenUpdating = False
mFile = "D:\temp\r75test.rtf"
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(mFile, ReadOnly:=True)
With wrdDoc
For p = 1 To .Paragraphs.Count
Set tRange = .Range(Start:=.Paragraphs(p).Range.Start, _
End:=.Paragraphs(p).Range.End)
tString = tRange.Text
Debug.Print tString '讀取之後其定位點的位置己不存在了
Next p
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
謝謝各位大大
R75TEST.rar (3.69 KB)
|
|