title image


Smiley Re: Kapitel markieren
Kannst Du ja mal

ausprobieren...



Gruß, C.











Option Explicit





Sub MarkiereBereichUeberschrift()

    

    Dim start1

    Dim end1

    Dim start2

    Dim end2

    

    

    start1 = Selection.Start

    end1 = Selection.End

    

    Selection.Collapse wdCollapseStart

    

    If Selection.Style = "Überschrift 1" Then

        start2 = Selection.Paragraphs(1).Range.Start

    Else

        Selection.GoToPrevious wdGoToHeading

        While Selection.Style <> "Überschrift 1"

            Selection.GoToPrevious wdGoToHeading

        Wend

        start2 = Selection.Start

    End If

    

    

    If IsLastHeading(Selection.Range) Then

        Selection.EndKey unit:=wdStory, Extend:=wdMove

        end2 = Selection.End

    Else

        Selection.GoToNext (wdGoToHeading)

        While Selection.Style <> "Überschrift 1"

            Selection.GoToNext wdGoToHeading

        Wend

        end2 = Selection.Start - 1

    End If

    

    Selection.Start = start2

    Selection.End = end2

    

    Selection.Copy

    

    Selection.Start = start1

    Selection.End = end1

    

    Documents.Add



    Selection.Paste



End Sub



Function IsLastHeading(Range1) As Boolean



    Dim s1

    Dim e1

    

    

    s1 = Selection.Start

    e1 = Selection.End

    

    Selection.EndKey unit:=wdStory, Extend:=wdMove

    

    If Selection.Style = "Überschrift 1" Then

        If Range1.Paragraphs(1).Range <> Selection.Paragraphs(1).Range Then

            IsLastHeading = False

        Else

            IsLastHeading = True

        End If

    Else

        Selection.GoToPrevious (wdGoToHeading)

        If Range1.Paragraphs(1).Range <> Selection.Paragraphs(1).Range Then

            IsLastHeading = False

        Else

            IsLastHeading = True

        End If

    End If

    

    Selection.Start = s1

    Selection.End = e1

    

End Function







Code eingefügt mit Syntaxhighlighter 2.4



















geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: