我有大型MS Word 2010文档,其中包含“框架”中的数据,至少这是我认为的。这是一个截图:
我试过这个来访问它:
Sub test()
Dim s As Shape
Dim i As Integer
Dim str As String
For Each s In ActiveDocument.Shapes
i = i + 1
If s.TextFrame.HasText Then
Application.StatusBar = i
End If
Next s
MsgBox ("done")
End Sub
但它不会让我在那里。我需要经历所有这些“框架”,但是,我甚至不确定它是什么,并将其转储到Excel中。有什么指针吗?我可以提取xml并解析它,但似乎有点矫枉过正。 (+我解析时不太好。)
答案 0 :(得分:0)
我的* .rtf文件包含来自Oracle Reports的框架。试试我的宏。
Sub test()
Dim TabHourFrames() As Variant
numb_frames = ActiveDocument.Frames.Count
ReDim TabHourFrames(1 To numb_frames)
counter = numb_frames
For i = 1 To counter
Set myRange = ActiveDocument.Frames.Item(i).Range
t = myRange.Text
TabHourFrames(i) = t
Next i
Documents.Add DocumentType:=wdNewBlankDocument
For q = 1 To counter
last_par = ActiveDocument.Paragraphs.Count
Set rngLastParagraph = ActiveDocument.Paragraphs(last_par).Range
With rngLastParagraph
.InsertAfter Text:=TabHourFrames(q)
.InsertParagraphAfter
End With
Next q
ActiveDocument.Range(0, 0).Select
End Sub