Je cherche un mot dans un document word, j'ai le bout de code ( non
optimisé ) qui fonctionne.
Function CountObjectifs(StrFnd, AllDoc As Boolean) As Byte
Dim y As Integer
On Error Resume Next
' Cette fonction devient folle en mode protégé
ActiveDocument.Unprotect Password:=""
If AllDoc Then
With ActiveDocument.Content.Find
Do While .Execute(FindText:=StrFnd, Forward:=True, Format:=True,
MatchWholeWord:=True) = True
y = y + 1
Loop
End With
Else
With ActiveDocument.Sections(4).Range.Find
Do While .Execute(FindText:=StrFnd, Forward:=True, Format:=True,
MatchWholeWord:=True) = True
y = y + 1
Loop
End With
End If
CountObjectifs = y
'Remettons les choses comme elles étaient ...
ActiveDocument.Protect Password:="", NoReset:=True,
Type:=wdAllowOnlyFormFields
End Function
Le hic c'est que le mot que je cherche se retrouve en plusieurs fois dans le
texte. La seule différence c'est qu'elle est en gras et de taille 16 ce qui
la rend unique ...
Je voudrais savoir s'il est possible de trouver un mot par son format.