Thijs Zuidland
Nieuwe gebruiker
- Lid geworden
- 9 okt 2009
- Berichten
- 3
Ik heb een vraag over het koppelen van 2 na elkaar draaiende macro's.
De eerste macro draait over een journaal en zoekt naar namen.
Als hij er een gevonden heeft kleurt hij deze geel.
Daarna draait hij nogmaals en zoekt naar geboortedata. Bij het vinden wordt deze ook gekleurd.
Om ze naderhand terug te vinden in het document staan er 3 hekjes achter (zoeken met Ctrl F)
Echter hij zoekt afzonderlijk en niet samen
Dus niet op IF naam = .... AND geb.datum = ... THEN "kleur" de gegevens die gevonden zijn.
Vraag is kan iemand mij helpen met het koppelen van deze macro's en dat ze alleen met gevonden
combinatie
Vba code:
Sub sZoeknaamleden()
Dim sZoeknaamleden As String
Start:
Documents.Open FileName:="c:\lijst leden.doc"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "SUBJECT:"
.Forward = True
End With
Selection.Find.Execute
If Selection.Text = "SUBJECT:" Then
GoTo vervolg
Else
GoTo Einde
End If
vervolg:
Selection.TypeBackspace
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
sTrefwoord = Selection.Text
Bewerken:
Selection.HomeKey Unit:=wdStory
Documents.Open FileName:="c:\infodesk1\Journaal.doc"
Options.DefaultHighlightColorIndex = wdYellow
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = sZoeknaamleden
.Replacement.Text = sZoeknaamleden + " (###)"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
GoTo Start
Einde:
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.SaveAs FileName:="c:\tmp.doc"
ActiveDocument.Close
End Sub
Sub sZoekGeboorteleden()
Dim sZoekGeboorteleden As String
Start:
Documents.Open FileName:="c:\lijst leden.doc"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "GEB:"
.Forward = True
End With
Selection.Find.Execute
If Selection.Text = "GEB:" Then
GoTo vervolg
Else
GoTo Einde
End If
vervolg:
Selection.TypeBackspace
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
sTrefwoord = Selection.Text
Bewerken:
Selection.HomeKey Unit:=wdStory
Documents.Open FileName:="c:\infodesk1\Journaal.doc"
Options.DefaultHighlightColorIndex = wdYellow
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = sZoekGeboorteleden
.Replacement.Text = sZoekGeboorteleden + "(###)"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
GoTo Start
Einde:
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.SaveAs FileName:="c:\tmp.doc"
ActiveDocument.Close
End Sub
De eerste macro draait over een journaal en zoekt naar namen.
Als hij er een gevonden heeft kleurt hij deze geel.
Daarna draait hij nogmaals en zoekt naar geboortedata. Bij het vinden wordt deze ook gekleurd.
Om ze naderhand terug te vinden in het document staan er 3 hekjes achter (zoeken met Ctrl F)
Echter hij zoekt afzonderlijk en niet samen
Dus niet op IF naam = .... AND geb.datum = ... THEN "kleur" de gegevens die gevonden zijn.
Vraag is kan iemand mij helpen met het koppelen van deze macro's en dat ze alleen met gevonden
combinatie
Vba code:
Sub sZoeknaamleden()
Dim sZoeknaamleden As String
Start:
Documents.Open FileName:="c:\lijst leden.doc"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "SUBJECT:"
.Forward = True
End With
Selection.Find.Execute
If Selection.Text = "SUBJECT:" Then
GoTo vervolg
Else
GoTo Einde
End If
vervolg:
Selection.TypeBackspace
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
sTrefwoord = Selection.Text
Bewerken:
Selection.HomeKey Unit:=wdStory
Documents.Open FileName:="c:\infodesk1\Journaal.doc"
Options.DefaultHighlightColorIndex = wdYellow
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = sZoeknaamleden
.Replacement.Text = sZoeknaamleden + " (###)"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
GoTo Start
Einde:
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.SaveAs FileName:="c:\tmp.doc"
ActiveDocument.Close
End Sub
Sub sZoekGeboorteleden()
Dim sZoekGeboorteleden As String
Start:
Documents.Open FileName:="c:\lijst leden.doc"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "GEB:"
.Forward = True
End With
Selection.Find.Execute
If Selection.Text = "GEB:" Then
GoTo vervolg
Else
GoTo Einde
End If
vervolg:
Selection.TypeBackspace
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
sTrefwoord = Selection.Text
Bewerken:
Selection.HomeKey Unit:=wdStory
Documents.Open FileName:="c:\infodesk1\Journaal.doc"
Options.DefaultHighlightColorIndex = wdYellow
Selection.Find.Replacement.Highlight = True
With Selection.Find
.Text = sZoekGeboorteleden
.Replacement.Text = sZoekGeboorteleden + "(###)"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
GoTo Start
Einde:
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.SaveAs FileName:="c:\tmp.doc"
ActiveDocument.Close
End Sub