Dim
aDoc
As
Word.Document
Dim
x
As
Long
, i
As
Long
Dim
BookMarkRange
As
Word.Range
Set
aDoc = ActiveDocument
If
aDoc.Bookmarks.Count >= 1
Then
i = 0
For
Each
BookMarkRange
In
aDoc.StoryRanges
Do
While
Not
BookMarkRange
Is
Nothing
If
BookMarkRange.StoryType = wdMainTextStory
Then
For
x = 1
To
BookMarkRange.Bookmarks.Count
i = i + 1
strArray(i) = BookMarkRange.Bookmarks(x).Name
Next
x
End
If
Set
BookMarkRange = BookMarkRange.NextStoryRange
Loop
Next
For
x = 1
To
i
If
x <= i
Then
Dim
y
As
String
y = strArray(x + 1)
Dim
oRange
As
Range
If
aDoc.Bookmarks.Exists(strArray(x))
And
aDoc.Bookmarks.Exists(y)
Then
Set
oRange = aDoc.Range(Start:=aDoc.Bookmarks(strArray(x)).Range.Start, _
End
:=aDoc.Bookmarks(y).Range.Start)
oRange.
Select
Else
MsgBox
"Es ist ein Fehler aufgetreten: Die Textmarken `"
& strArray(x) &
"` oder `"
& y &
"` existieren nicht mehr."
End
If
Else
aDoc.Range(Start:=aDoc.Bookmarks(strArray(x)).Range.Start,
End
:=aDoc.Range.
End
).
Select
End
If
Selection.Copy
Dim
nDoc
As
Word.Document
Set
nDoc = Documents.Add
Selection.Paste