Word VBA-macro's - Woorden tellen in selectie

Woorden tellen in selectie

Deze Word VBA-macro telt het aantal woorden in de selectie. Als er geen selectie wordt gemaakt, wordt het aantal woorden in het hele document geteld.

Sub WordCount() 'telt het hele document, daarna het aantal woorden voor selectie (als er iets is geselecteerd) Dim nWordsCount As Long Dim nCharCount As Long nWordsCount = ActiveDocument.Range.ComputeStatistics(wdStatisticWords) nCharCount = ActiveDocument.Range.ComputeStatistics(wdStatistics(wdStatistics) Het hele document bevat: " & vbCrLf & nWordsCount & " words and" & vbCrLf & _ nCharCount & " characters without spaties", , "Word Count" 'toon nu het aantal woorden voor geselecteerde tekst If Selection.Words.Count >= 1 And Selection.Type wdSelectionIP Dan nWordsCount = Selection.Range.ComputeStatistics(wdStatisticWords) nCharCount = Selection.Range.ComputeStatistics(wdStatisticCharacters) MsgBox "Geselecteerde tekst bevat: " & vbCrLf & nWordsCount & "woorden en" & vb spaties", , "Woordentelling (selectie)" End If End Sub 

U zal helpen de ontwikkeling van de site, het delen van de pagina met je vrienden

wave wave wave wave wave