habe das schnell mal geändert, sodass die unbekannten Wörter löscht.
Nutzung auf eigene Verantwortung - komm' mir hinterher nicht, dass Deine Texte weg sind
Verwendet wird zur Prüfung das Standard-Wörterbuch standard.dic. Im Code kann ein anderes eingestellt werden.
Code: Alles auswählen
Sub delUnknownWords
' ===============================================
' !!!
' Name des Wörterbuchs
' !!!
sWordBook = "standard.dic"
' ===============================================
sMakroName = "delUnknownWords"
sMakroVersion = "1.0.0"
sMakroTitel = _
 sMakroName & "-" & sMakroVersion
oDocModel = _
 StarDesktop.CurrentFrame.Controller.getModel()
If IsNull(oDocModel) Then
  ' Kein aktives Dokument
  MsgBox _
  "Kein aktives Dokument gefunden; beende Makro" ,_
  ,_
  sMakroTitel
  ' MsgBox("There's no active document")
  Exit Sub
End If
If Not HasUnoInterfaces ( _
 oDocModel, _
 "com.sun.star.text.XTextDocument") Then
 MsgBox _
 "Kein Textdokument; beende Makro" ,_
 ,_
 sMakroTitel
 ' MsgBox("This document doesn't support the 'XTextDocument' interface." + Chr(13))
 Exit Sub
End If
' service
oWBListe = _
 createUnoService ("com.sun.star.linguistic2.DictionaryList")
' Wörterbuch (WB)
' Name des Standards: standard.dic
oWB = _
 oWBListe.getDictionaryByName( sWordBook )
If IsNull( oWB ) Then
  ' Wörterbuch nicht gefunden
  MsgBox _
  "Wörterbuch " & sWordBook & " nicht gefunden; beende Makro" ,_
  ,_
  sMakroTitel
  ' MsgBox("There's no active document")
  Exit Sub
End If
oTextCursor = oDocModel.Text.createTextCursor()
oTextCursor.gotoStart(False)
oLinguSvcMgr = _
 createUnoService( _
 "com.sun.star.linguistic2.LinguServiceManager" _
 )
If Not IsNull(oLinguSvcMgr) Then
 oSpellChk = oLinguSvcMgr.getSpellChecker()
End If
If IsNull (oSpellChk) Then
 msgbox _
 "Zugriff auf Rechtschreibprüfung fehlgeschlagen; beende Makro",_
 ,_
 sMakroTitel
 ' MsgBox("It's not possible to access to the spellcheck." + Chr(13))
 Exit Sub
End If
' Schleife
Do
 ' Wort markieren
 If oTextCursor.isStartOfWord() Then
    oTextCursor.gotoEndOfWord(True)
    
    If Not isEmpty _
    (oTextCursor.getPropertyValue("CharLocale")) Then
     '
     If Not _
      oSpellChk.isValid(oTextCursor.getString(), _
      oTextCursor.getPropertyValue("CharLocale").Language, _
      aProp()) Then
         oTextCursor.setString( "" )
      End If
    End If
 End If
Loop While oTextCursor.gotoNextWord(False)
End SubViel Erfolg damit!
OOoWiki:
Makros installieren
Makros mit einem Klick