Word VBA -makroer - Tell ord i utvalg

Innholdsfortegnelse

Telle ord i utvalg

Denne Word VBA -makroen vil telle antall ord i utvalget. Hvis det ikke gjøres noe valg, vil det telle antall ord i hele dokumentet.

Sub WordCount () 'teller hele doc, deretter ordtelling for valg (hvis noe er valgt) Dim nWordsCount As Long Dim nCharCount As Long nWordsCount = ActiveDocument.Range.ComputeStatistics (wdStatisticWords) nCharCount = ActiveDocument.Range.ComputeStatistics (wdStatisticCharacters) Hele dokumentet inneholder: "& vbCrLf & nWordsCount &" ord og "& vbCrLf & _ nCharCount &" tegn uten mellomrom "," Word Count "'viser nå ordtelling for valgt tekst If Selection.Words.Count> = 1 And Selection.Type wdSelectionIP Deretter nWordsCount = Selection.Range.ComputeStatistics (wdStatisticWords) nCharCount = Selection.Range.ComputeStatistics (wdStatisticCharacters) MsgBox "Utvalgt tekst inneholder:" & vbCrLf & nWordsCount & "ordC" og "ogC" mellomrom ",," Word Count (utvalg) "End If End Sub 

Du vil bidra til utvikling av området, dele siden med vennene dine

wave wave wave wave wave