happyeater
Grünschnabel
Liebe *,
ich möchte einen Bereich in einem Word-Dokument daraufhin überprüfen, ob bestimmte (bei der Weiterverarbeitung unerlaubte) Textformatierungen vorliegen (z.B. doppelt durchgestrichen oder fett&unterstrichen).
Dazu fallen mir zwei Lösungsmöglichkeiten ein:
1. Im Text "blind" nach den Formatierungen suchen
2. Den Text Wort für Wort durchgehen und jedes Wort auf die Textformatierung hin überprüfen.
Leider bin ich kein Experte in VB, daher weiß ich nicht, ob Möglichkeit 1 überhaupt geht. Ich habe mich jedenfalls für Möglichkeit 2 entschieden und löse das so, wie im untenstehenden Code gezeigt.
Problem: Das ist saulangsam. Wenn der Text bloß eine Din-A4-Seite lang ist, kann man während der Überprüfung schon fast einkaufen gehen. Daher die Frage: Hat jemand einen Vorschlag, wie das auch schneller geht?
Vielen Dank!
happyeater
ich möchte einen Bereich in einem Word-Dokument daraufhin überprüfen, ob bestimmte (bei der Weiterverarbeitung unerlaubte) Textformatierungen vorliegen (z.B. doppelt durchgestrichen oder fett&unterstrichen).
Dazu fallen mir zwei Lösungsmöglichkeiten ein:
1. Im Text "blind" nach den Formatierungen suchen
2. Den Text Wort für Wort durchgehen und jedes Wort auf die Textformatierung hin überprüfen.
Leider bin ich kein Experte in VB, daher weiß ich nicht, ob Möglichkeit 1 überhaupt geht. Ich habe mich jedenfalls für Möglichkeit 2 entschieden und löse das so, wie im untenstehenden Code gezeigt.
Problem: Das ist saulangsam. Wenn der Text bloß eine Din-A4-Seite lang ist, kann man während der Überprüfung schon fast einkaufen gehen. Daher die Frage: Hat jemand einen Vorschlag, wie das auch schneller geht?
Vielen Dank!
happyeater
Code:
For i = 1 To (ActiveDocument.Tables(2).Rows.Count - 2)
zelle = ActiveDocument.Tables(2).Cell(i, 2)
zelle.Select
intWoerter = Selection.Words.Count - 1
For j = 1 To intWoerter
If ((Selection.Words(j).Font.Underline And Selection.Words(j).Font.Bold) _
Or (Selection.Words(j).Font.DoubleStrikeThrough) _
Or (Selection.Words(j).Font.Animation) _
Or (Selection.Words(j).Font.Emboss) _
Or (Selection.Words(j).Font.Engrave) _
Or (Selection.Words(j).Font.Outline) _
Or (Selection.Words(j).Font.Shadow) _
Or (Selection.Words(j).Font.StrikeThrough And Selection.Words(j).Font.Bold) _
Or (Selection.Words(j).Font.StrikeThrough And Selection.Words(j).Font.Underline) _
Or (Selection.Words(j).Font.StrikeThrough And Selection.Words(j).Font.Italic) _
Or (Selection.Words(j).Font.SmallCaps And Selection.Words(j).Font.Bold) _
Or (Selection.Words(j).Font.SmallCaps And Selection.Words(j).Font.StrikeThrough) _
Or (Selection.Words(j).Font.SmallCaps And Selection.Words(j).Font.Underline) _
Or (Selection.Words(j).Font.SmallCaps And Selection.Words(j).Font.Italic) _
Or (Selection.Words(j).Font.SmallCaps And Selection.Words(j).Font.Superscript) _
Or (Selection.Words(j).Font.Underline And Selection.Words(j).Font.Superscript) _
Or (Selection.Words(j).Font.Underline And Selection.Words(j).Font.Subscript) _
Or (Selection.Words(j).Font.Bold And Selection.Words(j).Font.Superscript) _
Or (Selection.Words(j).Font.Bold And Selection.Words(j).Font.Subscript) _
Or (Selection.Words(j).Font.Italic And Selection.Words(j).Font.Superscript) _
Or (Selection.Words(j).Font.Italic And Selection.Words(j).Font.Subscript)) _
Then
MsgBox("Fehlermeldung")
End If ' Doppelformatierungen
Next ' jedes einzelne Wort pruefen
Next ' jede Tabellenzeile durchgehen