Sub Aantal_Blz()
Dim No_Of_Pages As Long
Dim myloop As Long
Dim myrange As Range
Dim mytitle As String
No_Of_Pages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
For myloop = 1 To No_Of_Pages
Set myrange = ActiveDocument.Range(Start:=0, End:=0)
With myrange.Find
.ClearFormatting
.Text = "Blz. " & myloop & " van " & No_Of_Pages
With .Replacement
.ClearFormatting
.Text = ""
End With
.Execute Replace:=wdReplaceAll, _
Format:=True, MatchCase:=True, _
MatchWholeWord:=True
End With
Next myloop
'Ga naar begin van het document
Selection.HomeKey unit:=wdStory
'Eerste maal zoeken naar titel want hier moet geen
'harde pagina worden gezet
Beep
mytitle = InputBox("Geef exacte rapporttitel ...", "Zoek titel ...")
With Selection.Find
.Text = mytitle
.Forward = True
.Format = False
.Execute
End With
'ga naar het einde van de regel (zin)
Selection.EndKey unit:=wdLine
Do
With Selection.Find
'Aanpassen aan de titel van je eigen rapport
.Text = mytitle
.Forward = True
.Format = False
End With
'Als titel niet meer gevonden wordt, zal lus eindigen
'dmv de exit sub
If Selection.Find.Execute = False Then
MsgBox "Alle titels werden behandeld", vbInformation, "Titels verwerken ..."
Selection.HomeKey unit:=wdStory
Exit Sub
Else
'Titel wel gevonden, ga naar begin van de regel
'voeg pagina einde toe en ga naar einde van de regel (zin)
Selection.HomeKey unit:=wdLine
Selection.InsertBreak Type:=wdPageBreak
Selection.EndKey unit:=wdLine
End If
Loop
End Sub
Charlize