![]() |
Tipp 0025
|
Abschnittswechsel löschen
|
 |
|
Autor/Einsender: Datum: |
|
Angie 28.01.2005 (Update) |
|
Entwicklungsumgebung: |
|
Word 97 |
|
|
Bei der Erstellung von Serienbriefen und Etiketten werden je nach Größe der Datenquelle
unzählige Abschnittswechsel eingefügt, die oft unerwünscht sind. Der folgende Beispiel-Code
löscht diese aus dem aktiven Dokument.
|
|
|
Option Explicit
Sub DeleteSectionBreaks()
Dim nSectionsCnt As Integer
Dim blnOptPagination As Boolean
Dim rngSelRange As Range
nSectionsCnt = ActiveDocument.Sections.Count
If nSectionsCnt > 1 Then
blnOptPagination = Options.Pagination
Options.Pagination = False
Application.ScreenUpdating = False
With ActiveDocument.ActiveWindow
Set rngSelRange = .Selection.Range
.Selection.HomeKey unit:=wdStory
.Selection.Find.ClearFormatting
.Selection.Find.Replacement.ClearFormatting
Do Until nSectionsCnt = 1
nSectionsCnt = nSectionsCnt - 1
With .Selection.Find
.Text = "^b"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
.Selection.Find.Execute
.Selection.Delete unit:=wdCharacter, Count:=1
Loop
If Not rngSelRange Is Nothing Then
.Selection.SetRange _
rngSelRange.Start, rngSelRange.End
Set rngSelRange = Nothing
End If
End With
Options.Pagination = blnOptPagination
Application.ScreenUpdating = True
MsgBox "Fertig!"
Else
MsgBox "In diesem Dokument ist nur ein Abschnitt !"
End If
End Sub
|
|
|
|
In der im Download befindlichen *.bas-Datei ist der Code ausführlich kommentiert.
Die Datei kann in Word im VB-Editor importiert werden.
|
|
Windows-Version |
95 |
 |
|
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
Word-Version |
95 |
 |
|
97 |
 |
|
2000 |
 |
|
2002
(XP) |
 |
|
2003 |
 |
|
2007 |
 |
|
2010 |
 |
|
|
|
Download (1,6 kB)
|
Downloads bisher: [ 1085 ]
|
|
|