REM ***** BASIC ***** Sub LimitCount 'Written by Kliment Yanev 'Asks the user for a word limit then shows the current 'word count and a progress bar that fills as word limit 'is approached in the status bar number=0 thiscomponent.currentcontroller.statusindicator.end() limit=cint(InputBox ("Limit:","Enter word limit")) unit=thiscomponent.CurrentController.StatusIndicator oldnumber=-1 Do while true number=thiscomponent.WordCount if (number <> oldnumber) then unit.end() unit.start("Word Count: " + number, limit) unit.setText("Word Count: " + number) unit.setValue(number) oldnumber=number wait 200 end if ''uncomment lines below to cause it to disappear after ''given time (in milliseconds) wait 2000 is 2 seconds 'wait 2000 'unit.end() Loop End Sub Sub ClearStatus 'This clears the progress indicator in the status bar thiscomponent.currentcontroller.statusindicator.end() End Sub Sub LoopCount 'Written by Kliment Yanev 'Shows wordcount in status bar every time word count changes, 'it remains there for two seconds then disappears thiscomponent.currentcontroller.statusindicator.end() oldnumber=0 wait 2000 Do while true unit=thiscomponent.CurrentController.StatusIndicator number=thiscomponent.WordCount if (number <> oldnumber) then unit.start("Word Count: " + number, 0) oldnumber=number 'change the next line if you want the time to be different wait 2000 end if 'remove next line to make indicator stay in status bar permanently unit.end() Loop End Sub Sub Countchars ' Daniel Vogelheim wrote this ' displays a message box with number of characters and words in the current selection, and in the document ' ' get the document, and the currently selected text xDocument = thiscomponent xSelection = xDocument.getCurrentSelection() nSelCount = xSelection.getCount() ' access document statistics nAllChars = xDocument.CharacterCount nAllWords = xDocument.WordCount ' initialize counts nSelChars = 0 nSelWords = 0 ' iterate over multiple selection for nSel = 0 to nSelCount - 1 sText = xSelection.getByIndex(nSel).getString() ' count word in sText by scanning the selected text character for character nCount = Len(sText) bLastWasseparator = true 'first letter starts a word for i=1 to nCount Select Case Mid(sText,i,1) 'Add your own separators here 'chr(9) is a tab Case " ", "(", ")", chr(9) bLastWasseparator = true nSelChars = nSelChars + 1 'chr(10) and chr(13) are for Line- and Paragraph-ends 'Case chr(10), chr(13) bLastWasseparator = true 'Character found, so this is no separator Case Else 'Increase the number of words only if the last character was a separator '(i.e., if we're at the start of a word) if bLastWasseparator then nSelWords = nSelWords + 1 Endif nSelChars = nSelChars + 1 bLastWasseparator = false End Select next i next nSel ' Daniel Vogelheim's messagebox is the line commented out here. Mine is the uncommented one below it ' msgbox "Document" + chr(13) + " chars: " + nAllChars + chr(13) + " words: " + nAllWords + chr(13) + chr(13) + "Selection" + chr(13) + " chars: " + nSelChars + chr(13) + " words: " + nSelWords, 64, "Word counts in Document" msgbox "Document count:" + chr(13) + nAllWords +" words. " + chr(13) + chr(13) + "Selected text count:" + chr(13) + nSelWords + " words.", 64, "Words in Document" End Sub