Kazalo
Štej besede pri izbiri
Ta makro Word VBA bo prešteval število besed v izboru. Če ni izbranega, bo štelo število besed v celotnem dokumentu.
Sub WordCount () 'šteje celoten dokument, nato pa štetje besed za izbiro (če je nekaj izbrano) Dim nWordsCount As Long Dim nCharCount As Long nWordsCount = ActiveDocument.Range.ComputeStatistics (wdStatisticWords) nCharCount = ActiveDocument.Range.ComputeStatistics Celoten dokument vsebuje: "& vbCrLf & nWordsCount &" besede in "& vbCrLf & _ nCharCount &" znaki brez presledkov ",," Število besed "" zdaj prikaži število besed za izbrano besedilo If Selection.Words.Count> = 1 In Selection.Type wdSelectionIP Nato nWordsCount = Selection.Range.ComputeStatistics (wdStatisticWords) nCharCount = Selection.Range.ComputeStatistics (wdStatisticCraracters) MsgBox "Izbrano besedilo vsebuje:" & vbCrLf & nBr & nBr presledki ",," Število besed (izbor) "End If End Sub