Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
AB
Bonjour, Essaie ça (il y a sans doute plus élégant, mais ça marche) : AB
Selection.HomeKey With Selection.Find .Forward = True .ClearFormatting .MatchWholeWord = True .MatchCase = False .Wrap = wdFindContinue .Execute FindText:="function" Selection.Extend Selection.Extend Selection.Extend Selection.Extend Options.DefaultHighlightColorIndex = wdYellow Selection.Range.HighlightColorIndex = wdYellow End With End Sub
PierreAlain wrote: || Bonjour, || || je cherche à faire une macro qui : || || 1) détecte un mot particulier ( en l'occurence "function" ) || 2) surligne en jaune le paragraphe concerné. || || J'ai fait pas mal de tentatives, aucune concluente. || || -- || || Pierre Alain || ||
Bonjour,
Essaie ça (il y a sans doute plus élégant, mais ça marche) :
AB
Selection.HomeKey
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:="function"
Selection.Extend
Selection.Extend
Selection.Extend
Selection.Extend
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
End With
End Sub
PierreAlain wrote:
|| Bonjour,
||
|| je cherche à faire une macro qui :
||
|| 1) détecte un mot particulier ( en l'occurence "function" )
|| 2) surligne en jaune le paragraphe concerné.
||
|| J'ai fait pas mal de tentatives, aucune concluente.
||
|| --
||
|| Pierre Alain
||
|| webmaster@lifnet.org
Bonjour, Essaie ça (il y a sans doute plus élégant, mais ça marche) : AB
Selection.HomeKey With Selection.Find .Forward = True .ClearFormatting .MatchWholeWord = True .MatchCase = False .Wrap = wdFindContinue .Execute FindText:="function" Selection.Extend Selection.Extend Selection.Extend Selection.Extend Options.DefaultHighlightColorIndex = wdYellow Selection.Range.HighlightColorIndex = wdYellow End With End Sub
PierreAlain wrote: || Bonjour, || || je cherche à faire une macro qui : || || 1) détecte un mot particulier ( en l'occurence "function" ) || 2) surligne en jaune le paragraphe concerné. || || J'ai fait pas mal de tentatives, aucune concluente. || || -- || || Pierre Alain || ||
Guy Moncomble
Bonjour à tous, dans le message ,
Oui, et l'on tient compte du fait que function peut avoir une capitale majuscule :
Public Sub toto() Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .MatchWildcards = True .Text = "[F,f]unction" While .Execute Selection.Paragraphs(1).Range.Select Selection.Range.HighlightColorIndex = wdYellow Selection.Collapse wdCollapseEnd Wend End With End Sub
-- A+
GMO MVP WORD
Bonjour à tous,
dans le message <uNQeir3qDHA.2772@TK2MSFTNGP10.phx.gbl>,
Oui, et l'on tient compte du fait que function peut avoir une capitale
majuscule :
Public Sub toto()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.MatchWildcards = True
.Text = "[F,f]unction"
While .Execute
Selection.Paragraphs(1).Range.Select
Selection.Range.HighlightColorIndex = wdYellow
Selection.Collapse wdCollapseEnd
Wend
End With
End Sub
Oui, et l'on tient compte du fait que function peut avoir une capitale majuscule :
Public Sub toto() Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .MatchWildcards = True .Text = "[F,f]unction" While .Execute Selection.Paragraphs(1).Range.Select Selection.Range.HighlightColorIndex = wdYellow Selection.Collapse wdCollapseEnd Wend End With End Sub
-- A+
GMO MVP WORD
AB
Ah, merci Guy ! D'autant qu'à la réflexion, je pense que mon brouillon de macro ne fonctionne qu'une fois. Ca m'apprendra à répondre trop vite :) A+ André
Guy Moncomble wrote: || Bonjour à tous, || dans le message , || || Oui, et l'on tient compte du fait que function peut avoir une || capitale majuscule : || || || Public Sub toto() || Selection.HomeKey Unit:=wdStory || Selection.Find.ClearFormatting || Selection.Find.Replacement.ClearFormatting || With Selection.Find || .MatchWildcards = True || .Text = "[F,f]unction" || While .Execute || Selection.Paragraphs(1).Range.Select || Selection.Range.HighlightColorIndex = wdYellow || Selection.Collapse wdCollapseEnd || Wend || End With || End Sub || || -- || A+ || || GMO MVP WORD
Ah, merci Guy !
D'autant qu'à la réflexion, je pense que mon brouillon de macro ne
fonctionne qu'une fois.
Ca m'apprendra à répondre trop vite :)
A+
André
Guy Moncomble wrote:
|| Bonjour à tous,
|| dans le message <uNQeir3qDHA.2772@TK2MSFTNGP10.phx.gbl>,
||
|| Oui, et l'on tient compte du fait que function peut avoir une
|| capitale majuscule :
||
||
|| Public Sub toto()
|| Selection.HomeKey Unit:=wdStory
|| Selection.Find.ClearFormatting
|| Selection.Find.Replacement.ClearFormatting
|| With Selection.Find
|| .MatchWildcards = True
|| .Text = "[F,f]unction"
|| While .Execute
|| Selection.Paragraphs(1).Range.Select
|| Selection.Range.HighlightColorIndex = wdYellow
|| Selection.Collapse wdCollapseEnd
|| Wend
|| End With
|| End Sub
||
|| --
|| A+
||
|| GMO MVP WORD
Ah, merci Guy ! D'autant qu'à la réflexion, je pense que mon brouillon de macro ne fonctionne qu'une fois. Ca m'apprendra à répondre trop vite :) A+ André
Guy Moncomble wrote: || Bonjour à tous, || dans le message , || || Oui, et l'on tient compte du fait que function peut avoir une || capitale majuscule : || || || Public Sub toto() || Selection.HomeKey Unit:=wdStory || Selection.Find.ClearFormatting || Selection.Find.Replacement.ClearFormatting || With Selection.Find || .MatchWildcards = True || .Text = "[F,f]unction" || While .Execute || Selection.Paragraphs(1).Range.Select || Selection.Range.HighlightColorIndex = wdYellow || Selection.Collapse wdCollapseEnd || Wend || End With || End Sub || || -- || A+ || || GMO MVP WORD
PierreAlain
Un grand merci à tous les deux.
Ca ressemble plus ou moins à ce que j'avais essayer, mais la votre a un très gros avantage : ELLE MARCHE :-)
--
Pierre Alain
Un grand merci à tous les deux.
Ca ressemble plus ou moins à ce que j'avais essayer, mais la votre a un très
gros avantage : ELLE MARCHE :-)