PDA

View Full Version : Solved: find and replace



rien
03-20-2009, 02:23 PM
Hallo,

Wie kan mij helpen,
ik heb het volgende probleem, ik moet copy /paste een bestand invoegen in een word document maar dit bestand wat ik invoeg heeft al paginanummers
Blz. 1 van 6 Deze regels staan niet in de footer maar in het document
Is het mogelijk met VBA om deze blz. regels in het hele document te verwijderen.
groet,
Rien:friends:




English Version Courtesy Google (http://translate.google.com)
Who can help me,
I have the following problem: I have to copy/paste a file into a word document but it has a page number (Ex. 1 of 6). Is it possible with VBA to remove the page numbers from the document?

Charlize
03-25-2009, 06:07 AM
Sub Aantal_Blz()
Dim No_Of_Pages As Long
Dim myloop As Long
Dim myrange As Range
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
End SubCharlize

rien
03-25-2009, 12:40 PM
Charlize,

Sorry, dat ik de post niet gemeld had als Thread Solved. Ik zal jouw oplossing toepassen. Het enige wat ik dan nog moet doen in dit document is de naam van het rapport weer op elke pagina als eerste regel zien te krijgen.
Misschien heb je daar nog een oplossing voor, ik heb het geprobeerd met search "rapport", daarna 1 regel naar boven en dan een CTRL+Enter om een harde pagina in te voegen. Maar dit werkt niet echt goed.

groet,Rien

Charlize
03-30-2009, 02:38 AM
Staat de rapporttitel reeds op elke bladzijde ? Probeer volgende oplossing eens.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 SubCharlize

rien
03-30-2009, 12:30 PM
Charlize,

Ik weet dat het niet gebruikelijk is, maar kan ik de bestanden naar jouw persoonlijk mailen, het in te voegen bestand is namelijk vertrouwelijk (bedrijfsgegevens).
Ik heb namelijk de indruk dat mijn vraag (probleem) niet helemaal duidelijk is.

groet,
Rien

ps. bedankt voor alle moeite

Gossioii3
04-17-2009, 01:24 PM
This is great! It really shows me where to expand my blog. I think that sometime in the future I might try to write a book to go along with my blog, but we will see…Good post with useful tips and ideas

Charlize
04-20-2009, 03:16 AM
This is great! It really shows me where to expand my blog. I think that sometime in the future I might try to write a book to go along with my blog, but we will see…Good post with useful tips and ideas?

What's the meaning ?

Charlize

rien
04-20-2009, 09:48 AM
Hallo Charlize,

Ik heb geen idee wie deze gebruiker is en wat hij wil. Ik ben bijzonder goed geholpen en de tread is afgemeld.

met vriendelijke groet,
Rien