Word VBA -makroer - tæl ord i udvalg

Indholdsfortegnelse

Tæl ord i udvalg

Denne Word VBA -makro tæller antallet af ord i markeringen. Hvis der ikke vælges, tæller det antallet af ord i hele dokumentet.

Sub WordCount () 'tæller hele doc, derefter word Count for valg (hvis noget er valgt) Dim nWordsCount As Long Dim nCharCount As Long nWordsCount = ActiveDocument.Range.ComputeStatistics (wdStatisticWords) nCharCount = ActiveDocument.Range.ComputeStatistics (wdStatisticCharacters) Hele dokumentet indeholder: "& vbCrLf & nWordsCount &" ord og "& vbCrLf & _ nCharCount &" tegn uden mellemrum ",," Word Count "'viser nu ordtælling for valgt tekst If Selection.Words.Count> = 1 And Selection.Type wdSelectionIP Herefter nWordsCount = Selection.Range.ComputeStatistics (wdStatisticWords) nCharCount = Selection.Range.ComputeStatistics (wdStatisticCharacters) MsgBox "Udvalgt tekst indeholder:" & vbCrLf & nWordsCount & "ord &" ogC "og" ord "og" ord "og" ord "og" nCords & " mellemrum ",," Ordetælling (markering) "Afslut hvis slut Sub 

Du vil bidrage til udviklingen af ​​hjemmesiden, at dele siden med dine venner

wave wave wave wave wave