Thursday, July 5, 2007

FW: WordTips for 29 March 2003

-----Original Message-----
From: WordTips [mailto:awyatt@dcomp.com]
Sent: Saturday, March 29, 2003 12:20 PM
To: samaruna@omantel.net.om
Subject: WordTips for 29 March 2003

WordTips for 29 March 2003 Copyright 2003 by DCI
**********************************************************************

In This Issue...
----------------
Publisher's Notes
Tips
* Find and Replace in Text Boxes
* Generating a Count of Word Occurrences
* Grouping Drawing Objects
* Saving Money on Printing Labels
Help Wanted
* Easily Backing Up AutoText Entries
* Alternate Ways of Creating Random Text
Publisher and Copyright Information
Important Links
Subscription Information


Help support WordTips and obtain a valuable resource by
purchasing your own copies of the WordTips archives. Visit the
Web site (http://store.vitalnews.com/wtarch.html) for more info,
or send a blank e-mail to WordTips-CDs@lists.vitalnews.com.


**********************************************************************
PUBLISHER'S NOTES * PUBLISHER'S NOTES * PUBLISHER'S NOTES
**********************************************************************

Did you know that WordTips sponsors an unmoderated mailing list that allows
Word users to communicate with each other very, very quickly?
DailyWordTips is a great forum if you have a question about how to use Word
or you have an answer to share. The DailyWordTips regulars are a great group
of people, and I have seen very few questions that they couldn't answer
post-haste.

If you want to check out DailyWordTips, visit this Web page:

http://www.vitalnews.com/wordtips/subscribe.htm

DailyWordTips is, again, a free service. I hope you enjoy it.

Speaking of free services, if you use Excel you should also check out
ExcelTips:

http://www.exceltips.com/

-Allen


**********************************************************************
TIPS * TIPS * TIPS * TIPS * TIPS * TIPS * TIPS * TIPS * TIPS
**********************************************************************
If you have an idea for a tip, send it our way. You can e-mail the
suggestion to awyatt@dcomp.com. Any tips contributed will be credited in the
issue in which they appear.


------------------------------
Find and Replace in Text Boxes
------------------------------
Subscriber Margaret Millgate wrote about a problem she was having performing
a find and replace for something in a text box. It seems that Margaret
created a merged document, and then noticed that a reference number in a
text box was incorrect. She tried to do a search and replace to change all
instances of the reference number, but Word would not find and replace it.

In doing some testing, it appears that Word will find information in a text
box and replace it just fine, provided that the text box is visible when you
actual do the find and replace operation. For instance, if you place some
text in a text box, and the same text in the main portion of the document,
and then do a find and replace operation for a piece of text that is common
to both the document and the text box, then Word will successfully replace
all the instances--even those in the text box.

Why wouldn't Word find and replace the reference number in Margaret's
situation? There are only a few possibilities. First, the reference number
may not really be text. If the reference number was made with an embedded
field, then the find and replace will not be reliable. For instance, if the
reference number is created with the SEQ field, you can find what is
displayed by the field, and you can replace it, but if the fields are
updated (which happens when you print), then the "replaced" number reverts
back to what the underlying field code tells it to be.

Second, if the reference number is linked in some way to another document
(again, using a field), then Word cannot correctly replace the information.
This is because the reference number is not in the current document, but in
another document linked to the current document. To make the change, you
would need to change the source document.

Finally, it could be that the reference number, if it was merged from
another data source, contains some non-printable characters that make
finding it impossible. For instance, let's say that the reference number you
want to find is QR378, but that the text in the merge source include a
non-printing character of some sort between the "R"
and the "3". If this is the case, then Word won't find the reference number
when you search for QR378. The only way to correct this situation is to
clean up the original data source and then run the merge again.

It should be noted that the discussion so far reflects the behavior of Word
if you are replacing text using the Find and Replace option from the Edit
menu. If you are actually doing the searching and replacing in a macro, it
is interesting that Word won't find appropriate text matches in text boxes.
You can, in fact, use the macro recorder to record a perfectly good Find and
Replace operation--that does find and replace text in a text box--and when
you later replay the macro, it won't find the information in the text box.

If you are doing your searching and replacing in a macro, the following
article by Doug Robbins on the Word MVP site explains what is going on:

http://www.mvps.org/word/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm

(Thanks to Albie Weiss, Richard Soans, Stephen Barrow, Dave Lett, and
Bernice Volinsky for contributing to this tip.)


------------------------------
Generating a Count of Word Occurrences
------------------------------
As you are analyzing your documents, you may wonder if there is a way to
create a count of the number of words in the document.
Unfortunately, Word doesn't include such a feature, but there are a couple
of things you can do.

First, if you want to know the number of times a specific word or phrase is
used, you can follow these steps:

1. Press Ctrl+H to display the Replace tab of the Find and Replace
dialog box.
2. In the Find What box, enter the word or phrase you want counted.
3. In the Replace With box, enter ^&. This character sequence tells
Word that you want to replace what you find with whatever you
placed in the Find What box. (In other words, you are replacing
the word or phrase with itself.)
4. If you are searching for individual words, make sure you click
the Find Whole Words Only check box.
5. Click on Replace All. Word makes the replacements and shows you
how many instances it replaced. That is the number you want.

This approach works great if you just have one or two words or phrases you
want to know about. You can automate the process a bit by using a macro to
search through the document and count for you. The following macro prompts
the user for a word, and then counts the number of times that word appears
in the document. It will continue to ask for another word until the user
clicks on the Cancel button.

Sub FindWords()
Dim sResponse As String
Dim iCount As Integer

' Input different words until the user clicks cancel
Do
' Identify the word to count
sResponse = InputBox(Prompt:="What word do you want to count?",
_
Title:="Count Words", Default:="")

If sResponse > "" Then
' Set the counter to zero for each loop
iCount = 0
Application.ScreenUpdating = False
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = sResponse
' Loop until Word can no longer
' find the search string and
' count each instance
Do While .Execute
iCount = iCount + 1
Selection.MoveRight
Loop
End With
' show the number of occurences
MsgBox sResponse & " appears " & iCount & " times"
End With
Application.ScreenUpdating = True
End If
Loop While sResponse <> ""
End Sub

If you want to determine all the unique words in a document, along with how
many times each of them appears in the document, then a different approach
is needed. The following VBA macro will do just that.

Sub WordFrequency()
Dim SingleWord As String 'Raw word pulled from doc
Const maxwords = 9000 'Maximum unique words allowed
Dim Words(maxwords) As String 'Array to hold unique words
Dim Freq(maxwords) As Integer 'Frequency counter for unique
words
Dim WordNum As Integer 'Number of unique words
Dim ByFreq As Boolean 'Flag for sorting order
Dim ttlwds As Long 'Total words in the document
Dim Excludes As String 'Words to be excluded
Dim Found As Boolean 'Temporary flag
Dim j, k, l, Temp As Integer 'Temporary variables
Dim tword As String '

' Set up excluded words
Excludes =
"[the][a][of][is][to][for][this][that][by][be][and][are]"

' Find out how to sort
ByFreq = True
ans = InputBox$("Sort by WORD or by FREQ?", "Sort order", "WORD")
If ans = "" Then End
If UCase(ans) = "WORD" Then
ByFreq = False
End If

Selection.HomeKey Unit:=wdStory
System.Cursor = wdCursorWait
WordNum = 0
ttlwds = ActiveDocument.Words.Count

' Control the repeat
For Each aword In ActiveDocument.Words
SingleWord = Trim(LCase(aword))
'Out of range?
If SingleWord < "a" Or SingleWord > "z" Then SingleWord = ""
'On exclude list?
If InStr(Excludes, "[" & SingleWord & "]") Then SingleWord = ""
If Len(SingleWord) > 0 Then
Found = False
For j = 1 To WordNum
If Words(j) = SingleWord Then
Freq(j) = Freq(j) + 1
Found = True
Exit For
End If
Next j
If Not Found Then
WordNum = WordNum + 1
Words(WordNum) = SingleWord
Freq(WordNum) = 1
End If
If WordNum > maxwords - 1 Then
j = MsgBox("The maximum array size has been exceeded.
Increase maxwords.", vbOKOnly)
Exit For
End If
End If
ttlwds = ttlwds - 1
StatusBar = "Remaining: " & ttlwds & " Unique: " & WordNum
Next aword

' Now sort it into word order
For j = 1 To WordNum - 1
k = j
For l = j + 1 To WordNum
If (Not ByFreq And Words(l) < Words(k)) Or (ByFreq And
Freq(l) > Freq(k)) Then k = l
Next l
If k <> j Then
tword = Words(j)
Words(j) = Words(k)
Words(k) = tword
Temp = Freq(j)
Freq(j) = Freq(k)
Freq(k) = Temp
End If
StatusBar = "Sorting: " & WordNum - j
Next j

' Now write out the results
tmpName = ActiveDocument.AttachedTemplate.FullName
Documents.Add Template:=tmpName, NewTemplate:=False
Selection.ParagraphFormat.TabStops.ClearAll
With Selection
For j = 1 To WordNum
.TypeText Text:=Trim(Str(Freq(j))) & vbTab & Words(j) &
vbCrLf
Next j
End With
System.Cursor = wdCursorNormal
j = MsgBox("There were " & Trim(Str(WordNum)) & " different words
", vbOKOnly, "Finished")
End Sub

When you open a document and run this macro, you are asked if you want to
create a list sorted by word or by frequency. If you choose word, then the
resulting list is shown in alphabetical order. If you choose frequency, then
the resulting list is in descending order based on how many times the word
appeared in the document.

While the macro is running, the status bar indicates what is happening.
Depending on the size of your document and the speed of your computer, the
macro may take a while to complete. (I ran it with a 719-page document with
over 349,000 words and it took about five minutes to complete.)

Note that there is a line in the macro that sets a value in the Excludes
string. This string contains words that the macro will ignore when putting
together the word list. If you want to add words to the list, simply add
them to the string, between [square brackets]. Also, make sure the exclusion
words are in lowercase.

If you don't like to use macros for some reason, there are other programs
you can use to create word counts. For instance, the NoteTab text editor
(the "light" version can be downloaded free at
http://www.notetab.com) includes a feature that provides a word count.
All you need to do is copy your entire document and paste it into NoteTab.
Then, within NoteTab, choose Tools | Text Statistics | More.
It presents an analysis of the word frequency, including percentages.

Another third-party tool that is handy for shorter documents is found here
on the Web:

http://www.georgetown.edu/faculty/ballc/webtools/web_freqs.html

Just paste your document text in the form, and the desired statistics are
returned.

(Thanks to Phil Rabichow, Jim D'Avis, Alec Donaldson, Tony Beckett, Bob
Jordan, Stephen Barrow, Tim Comber, Kathleen McGrath, David G.
Lett, Roger Kapp, Chat Chatterton, Les Landau, Bernard de Groot, Dan
Oswiecinski, David C. Ward, and Jan-Willem Lankhaar for contributing to this
tip.)


Got a Word-related product or service you want to let others
know about? Advertising in WordTips is a cost-effective way to let
thousands of serious Word users know about you. For more info,
visit the Web site (http://www.VitalNews.com/WordTips/), or send
a blank e-mail to WordTips-Advertising@lists.vitalnews.com.


------------------------------
Grouping Drawing Objects
------------------------------
After you have worked with the Drawing toolbar for a while, you will find
that you may have added quite a few objects to your document.
Some of these objects just naturally go together to create other objects.
For instance, you might have a text object that belongs inside a box. Word
lets you group objects together so they can be treated as a single object by
the program. In this way, you can select an entire collection of objects
with the same ease you would use in selecting one. To group objects
together, follow these steps:

1. Select all the objects that belong in the group.
2. Choose the Group option from the Draw menu on the Drawing
toolbar.

There may come a time when you need to ungroup the objects. For instance,
you may need to update one of the elements that make up your group. To
ungroup objects, follow these steps:

1. Select the grouped object.
2. Choose the Ungroup option from the Draw menu on the Drawing
toolbar.


------------------------------
Saving Money on Printing Labels
------------------------------
If you have purchased labels for your laser printer, you already know that
they can be a bit expensive. It can be frustrating to print your labels and
not have them lined up just right. Each bad sheet you print is effectively
money down the drain.

To overcome this problem, make sure you print a test sheet before you
actually print on the labels themselves. Simply put a blank sheet of paper
in the manual feed of your laser printer, instead of your label sheet. When
the information is printed on the blank sheet, place that sheet behind a
blank sheet of labels and hold it up to the light. The print on the paper
will show through the label sheet, and you can see how the text lines up.

The benefit of this is that you save money--the blank paper is much cheaper
than the label sheets. Continue printing your test sheets, adjusting the
print parameters as necessary in Word. When you are satisfied with how your
test sheet prints, go ahead and print on the labels themselves.


**********************************************************************
Step up to the PROFESSIONAL version of WordTips--WordTips Premium.
This week WordTips Premium subscribers also learned about:

* Ignoring Punctuation in Names
* Inserting the Document Revision Number
* Editing Word's Built-in Commands
* Determining if a Text Selection Exists

Each weekly newsletter is in professional PDF layout, and presents DOUBLE
THE TIPS (Premium subscribers see articles you won't in regular
WordTips) with great, useful graphics. Plus, WordTips Premium subscribers
get valuable money-saving benefits. For more information, (including a
sample issue) visit the following Web page:

http://store.vitalnews.com/premium.html


**********************************************************************
HELP WANTED * HELP WANTED * HELP WANTED * HELP WANTED
**********************************************************************
This section is for those having problems making Word behave. Having a
problem you want to see addressed? Send it to WTHelp@VitalNews.com.
Do you have an answer to the problems below? Send your answer to
WTAnswers@VitalNews.com (all responses become the sole property of DCI and
can be used in any way deemed appropriate). If your response is used in a
future issue, you will be credited for your contribution to the answer.


------------------------------
Easily Backing Up AutoText Entries
------------------------------
I am looking for a utility or macro that will back up my AutoText entries
quickly. Does anyone have suggestions on how to do this using either an
existing utility or a macro? (Elecia Almekinder)


------------------------------
Alternate Ways of Creating Random Text
------------------------------
I know about the undocumented RAND command for creating paragraphs and
sentences of "The quick brown fox jumps over the lazy dog." For example,
=rand(4,5) will create 4 paragraphs with 5 sentences each.
Are there other such commands for creating random text in Word? (Dan
Oswiecinski)


**********************************************************************
PUBLISHER and COPYRIGHT INFORMATION
**********************************************************************
WordTips (ISSN 1522-3744) is published weekly by Discovery Computing Inc.
(DCI), PO Box 2145, Mesa, AZ 85214. WordTips is a trademark of DCI.
Copyright 2003 by DCI, All Rights Reserved. All broadcast, publication, or
retransmission is strictly prohibited without prior written permission from
the publisher. Full information on distribution rights can be found in the
WordTips FAQ at the WordTips Web page.


**********************************************************************
IMPORTANT LINKS * IMPORTANT LINKS * IMPORTANT LINKS
**********************************************************************

WEB ADDRESSES
-------------
WordTips Web page -

http://www.VitalNews.com/wordtips/
WordTips Premium Web page -

http://store.VitalNews.com/premium.html
WordTips Archives -

http://store.VitalNews.com/wtarch.html
Advertising in WordTips -

http://www.VitalNews.com/advert.htm
Vital News Store -

http://store.VitalNews.com/


E-MAIL ADDRESSES
---------------
Help Wanted questions - WTHelp@VitalNews.com
WordTips sample issue - WordTips-Sample@lists.vitalnews.com
WordTips Premium info - WTPremium@VitalNews.com
WordTips Archive info - WordTips-CDs@lists.vitalnews.com
Advertising in WordTips - WordTips-Advertising@lists.vitalnews.com
Editor and Publisher - awyatt@dcomp.com


**********************************************************************
SUBSCRIPTION INFORMATION * SUBSCRIPTION INFORMATION
**********************************************************************
TO RECEIVE WordTips regularly via e-mail at no charge, send an e-mail to <
join-wordtips@lists.vitalnews.com >.

You are currently subscribed to wordtips as: [samaruna@omantel.net.om] To
unsubscribe, forward this message to
leave-wordtips-296702L@lists.vitalnews.com

No comments:

Business Line - Markets