[VBA-W] Comparer 2 string
Hello,
voilà j'ai un souci, surement tout bete,
voici mon texte dans word :
Citation:
Public function test as byte
mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Sub tests()
Debug.Print ThisDocument.Words.Count
For i = 1 To ThisDocument.Words.Count - 1
'If (CStr(ThisDocument.Words(i)) = "Public") Then
If (StrComp(ThisDocument.Words(i), "Public", 1) = 0) Then
MsgBox "hu"
End If
Next
End Sub |
j'ai essayé avec toutes les comparaisons que je connaissais, meme avec des Ucase etc... rien à faire je n'ai jamais le msgbox qui apparait. ThisDocument.Words.Count me renvoit 6 (j'ai cru deja voir qu'il y avait dans un doc vierge toujours 1 mot donc ca ne m'etonne pas de voir 6 en ayant 5 mots :P ) par contre pour le msgbox... :?