Private Sub Command1_Click() Text5.Text = VerifOrthographe(Text5.Text) End Sub Public Function VerifOrthographe(TxtVérif As String) As String 'Cette fonction ouvre un projet (invisible) Microsoft Word 'et utilise le vérificateur d'othographe. 'Les corrections sont récupérées. 'Variables Dim ObjMSWord As Object Dim TxtProv As String 'Y a-t'il du texte à vérifier ? If TxtVérif = "" Then MsgBox "Rien à vérifier !", vbExclamation Exit Function End If 'Pointeur "sablier" Screen.MousePointer = 11 'Définition de l'objet Word et appel de l'outil de vérification de l'orthographe Set ObjMSWord = CreateObject("Word.Basic") With ObjMSWord .FileNew .Insert TxtVérif .ToolsSpelling ObjMSWord.EditSelectAll .SetDocumentVar "TexteAVerifier", ObjMSWord.Selection End With 'Récupération du texte (corrigé) après vérification TxtProv = ObjMSWord.GetDocumentVar("TexteAVerifier") TxtProv = Left(TxtProv, Len(TxtProv) - 1) If TxtProv = "" Then 'Opération annulée par l'utilisateur VerifOrthographe = TxtVérif Else VerifOrthographe = TxtProv End If 'Fermeture du document provisoire et de Word ObjMSWord.FileCloseAll 2 ObjMSWord.AppClose Set ObjMSWord = Nothing 'Pointeur standard Screen.MousePointer = 0 'Message en cas de bon déroulement de l'opération If TxtProv = "" Then MsgBox "Vérification ignorée !", vbExclamation Else MsgBox "Vérification terminée !", vbInformation End If End Function
Public Function VerifOrthographe(TxtVérif As String) As String Let Me.WindowState = vbMinimized Let acceuil.WindowState = vbMinimized Let Rapport1.WindowState = vbMinimized Let Rapport2.WindowState = vbMinimized Let Rapport3.WindowState = vbMinimized Let Rapport4.WindowState = vbMinimized Let Rapport5.WindowState = vbMinimized 'Cette fonction ouvre un projet (invisible) Microsoft Word 'et utilise le vérificateur d'othographe. 'Les corrections sont récupérées. 'Variables Dim openwriter As Object Dim TxtProv As String 'Y a-t'il du texte à vérifier ? If TxtVérif = "" Then MsgBox "Rien à vérifier !", vbExclamation Exit Function End If 'Pointeur "sablier" Screen.MousePointer = 11 'Définition de l'objet Word et appel de l'outil de vérification de l'orthographe Set openwriter = CreateObject("Word.Basic") With openwriter .FileNew .Insert TxtVérif .ToolsSpelling openwriter.EditSelectAll .SetDocumentVar "TexteAVerifier", openwriter.Selection End With 'Récupération du texte (corrigé) après vérification TxtProv = openwriter.GetDocumentVar("TexteAVerifier") TxtProv = Left(TxtProv, Len(TxtProv) - 1) If TxtProv = "" Then 'Opération annulée par l'utilisateur VerifOrthographe = TxtVérif Else VerifOrthographe = TxtProv End If 'Fermeture du document provisoire et de Word openwriter.FileCloseAll 2 openwriter.AppClose Set openwriter = Nothing 'Pointeur standard Screen.MousePointer = 0 'Message en cas de bon déroulement de l'opération If TxtProv = "" Then MsgBox "Vérification ignorée !", vbExclamation Else MsgBox "Vérification terminée !", vbInformation End If Let acceuil.WindowState = vbNormal Let Rapport1.WindowState = vbNormal End Function
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionEt je voudrais savoir comment faire pour qu'il y est un correcteur d'orthographe en sachant que je ne posède par Word
J'ai trouver
'Cette fonction ouvre un projet (invisible) Microsoft Word
'et utilise le vérificateur d'othographe.
'Les corrections sont récupérées.