Thursday, July 5, 2007

FW: WordTips for 31 August 2002

-----Original Message-----
From: WordTips [mailto:awyatt@dcomp.com]
Sent: Saturday, August 31, 2002 10:10 AM
To: sathyamurthy@netkracker.com
Subject: WordTips for 31 August 2002

WordTips for 31 August 2002 Copyright 2002 by DCI
**********************************************************************

In This Issue...
----------------
Publisher's Notes
Tips
* Removing All Text Boxes In a Document
* Automatically Adding Tabs in Footnotes
* Inserting the User's Name
* An Automatic File Name
Help Wanted
* Specifying a Paper Tray in a Macro
* Pulling Headers and Footers from Other Files
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
**********************************************************************

This past week (Friday, to be exact) marked a time for a big change here.
The last issue of WordTips Gold--which I had published since April 2000--was
sent out to subscribers. WordTips Gold was a sister service to WordTips. It
was started so that subscribers would have an opportunity to receive the
older tips that appeared in past issues of WordTips.

Our business has changed quite a bit in the past two or three years, and
tips that appeared in past issues of WordTips are now easily available in
either handy archives or online, at WordTips Online Answers. For these
reasons, I decided to discontinue the publication of WordTips Gold as a
separate service.

All of the WordTips Gold subscribers who weren't already receiving regular
WordTips were signed up for that service, and today is the first day that
many of them have received WordTips. I wanted to welcome all the new
subscribers and hope that they enjoy the main WordTips publication.

If you are interested in back issues of WordTips for your own personal use,
I suggest you take a look at the archives that are available.
There are many benefits to have WordTips in this manner. You can find out
more here:

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

If you prefer to search and read content online, then you should also check
out WordTips Online Answers. Some tips at the site are accessible for free,
but you can access all the tips through a reasonable paid subscription. You
can find more information here:

http://wtonline.vitalnews.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.


------------------------------
Removing All Text Boxes In a Document
------------------------------
If you do a lot of work with documents from other people, you may have a
need to remove text boxes in those documents. If there are only one or two
text boxes in the document, it is not that difficult to select them and
delete them. What if there are 30, 40, or more text boxes, though? Deleting
them individually can quickly get tedious.

One potential solution is a "brute force" method. Follow these steps:

1. In your document, press Ctrl+A. The entire document is selected.
2. Press Ctrl+C. The document is now on the Clipboard.
3. Open a new, blank document.
4. Choose Paste Special from the Edit menu. Word displays the Paste
Special dialog box.
5. In the list of formats, choose Unformatted Text.
6. Click on OK.

The document text, minus the text boxes, is now in the new document.
The obvious drawback to this approach is that the other formatting of the
original document is also lost, and you must reformat the entire document.
(I told you this was a brute force method.)

If you want to get rid of only the text boxes, then the quickest solution is
to use a macro. The following macro will quickly remove all text boxes in
your document:

Sub RemoveTextBox1()
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then shp.Delete
Next shp
End Sub

You should realize that this macro removes all of the text boxes and their
contents. In other words, if a text box is used for placement of text, then
the text in that text box is deleted along with the text box itself.

If you prefer to transfer the text from the text boxes to the document,
prior to deleting the text box, then a slight modification on the above
macro will work:

Sub RemoveTextBox2()
Dim shp As Shape
Dim oRngAnchor As Range
Dim sString As String

For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then
' copy text to string, without last paragraph mark
sString = Left(shp.TextFrame.TextRange.Text, _
shp.TextFrame.TextRange.Characters.Count - 1)
If Len(sString) > 0 Then
' set the range to insert the text
Set oRngAnchor = shp.Anchor.Paragraphs(1).Range
' insert the textbox text before the range object
oRngAnchor.InsertBefore _
"Textbox start << " & sString & " >> Textbox end"
End If
shp.delete
End If
Next shp
End Sub

When this macro is done, you can do a search for "Textbox start" and you
will be at the beginning of text that used to be in the text boxes that are
now gone from your document. You can then edit the text so that it appears
as you want.

(Thanks to William Taylor, Jorge Posada, Claus Henriksen, Phil Rabichow,
Ventsi Gradinarov, Dave Lett, and Adrienne Dold for contributing to this
tip.)


------------------------------
Automatically Adding Tabs in Footnotes
------------------------------
For some formatting purposes, you may have a need for Word to place a tab
character in your footnotes, between the actual footnote reference number
and the text of the footnote. Word does not allow you to do this
automatically, however. In fact, Word doesn't allow you to specify what
character should appear between the footnote reference number and footnote
text, as you can with numbered lists. Instead, Word places a space between
these two elements.

There are several ways you can go about making sure that the footnote
includes a tab separator, and the various methods will be described shortly.
All of the methods assume, however, that you have the Footnote Text style
set up to handle the tab properly.

Whenever you insert a footnote, Word formats the footnote itself so that it
uses the built-in Footnote Text style. You can control how the footnote
appears by simply making changes to this built-in style. For instance, if
you want a tab character between the footnote reference number and the
beginning of the footnote text, then you should set a tab stop in the
Footnote Text style so that Word knows what to do with the tab character
once you get it in the footnote. Exactly how you modify styles has been
covered in other issues of WordTips.

The first potential solution to adding the tabs is to use Word's Find and
Replace feature. You can make sure that all footnotes have the requisite tab
character by following these steps:

1. Press Ctrl+H or choose Replace from the Edit menu. Word displays
the Replace tab of the Find and Replace dialog box.
2. If available, click on the More button.
3. Make sure that the Use Wildcards check box is selected.
4. In the Find What box, type "(^2) " without the quotes. Note
there's a space after the last parenthesis.
5. With the cursor still in the Find box, click on the Format
button, then choose Style. Word displays the Find Style dialog
box.
6. In the list of styles presented, choose the Footnote Text style
and click on OK.
7. In the Replace With box, type "\1^t" without the quotes.
8. Press Replace All, then close the Find and Replace dialog box.

When done, all of the footnotes will have the requisite tab between the
footnote reference number and the beginning of the footnote text.
This works because you are using the ^2 wildcard in the search, which
searches for footnote or endnote reference marks. The parentheses
surrounding the ^2 causes that wildcard to be treated as a group.
Essentially, the Find What box will look for all footnote or endnote
reference marks followed by a space that are in paragraphs formatted with
the Footnote Text style. The only place that this combination occurs is in
the footnote itself. Endnotes are in the endnote style, and the main body of
the document should not be in the Footnote Text style. In the Replace With
box, the character \1 will replace the first expression that is between
parentheses in the Find What box. In our case, that is the footnote
reference number. The ^t will insert a tab.

Another approach is to use a macro that will place the requisite tab in the
desired location in the footnotes. The following macro will do just that:

Sub TabFootnotes()
For s = 1 To ActiveDocument.Footnotes.Count
ActiveDocument.Footnotes(s).Range.Select
With Selection
.Collapse Direction:=wdCollapseStart
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.TypeText Text:=vbTab
End With
Next
End Sub

This macro steps through each footnote, selects the footnote text, deletes
the space at the beginning of the text, and then types a tab.
In reality, the macro does not check to make sure that the character at the
beginning of the text is a space; it could just as easily be a tab from a
previous invocation of this macro. That is OK, however, as replacing an
existing tab with a new tab will work just fine and still give the desired
results.

There is a final approach that is appropriate if you want to always make
sure there is a tab after the footnote reference number. This approach
involves replacing Word's built-in command for inserting
footnotes:

Sub InsertFootnote()
If Selection.StoryType <> wdFootnotesStory Then
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogInsertFootnote)
If dlg.Display = -1 Then
dlg.Execute
Selection.TypeBackspace
Selection.TypeText vbTab
End If
End If
End Sub

This macro first checks to make sure that you aren't trying to insert a
footnote while in the footnote section of the document. Then it displays the
regular Footnote and Endnote dialog box. When you click on OK in the dialog
box, the macro inserts a tab and waits for you to type the text of your
footnote. This macro will also insert tab characters between endnote
references and endnote text.

(Thanks to Hafizullah Chishti, Jorge Posada, Phil Rabichow, Ventsi
Gradinarov, Dave Lett, Tina Carter, and Adrienne Dold 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.


------------------------------
Inserting the User's Name
------------------------------
When you install Word, you are asked for your name. This information is
stored with Word, and you can later access it. For instance, Word allows you
to use your name in the return address of an envelope. If you want to
automatically insert the user name in your documents, you can follow these
steps:

1. Position the insertion point where you want the user name
inserted.
2. Choose Field from the Insert menu. You will see the Field dialog
box.
3. In the Categories list, choose User Information.
4. In the Field Names list choose UserName.
5. Click on OK.

------------------------------
An Automatic File Name
------------------------------
In the last tip you learned how you can set up a default file name that is
closer to what you really want to use. There is a logical extension to this
technique that allows you to quickly name your document by changing the
title of the document before displaying the Save As dialog box.

This particular macro is well-suited for use with letters, although it could
be easily modified for other types of documents. The macro is named
FileSaveAs, so it replaces the built-in Save As command. The best place to
save this macro is in the template you use for your
letters:

Public Sub FileSaveAs()
Dim MyDocTitle As String
MyDocTitle = Format(Date, "yymmdd") + " letter"

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^pDear "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

If Selection.Find.Found Then
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=2,
Extend:=wdExtend
If Len(Selection.Text) > 1 Then
MyDocTitle = MyDocTitle + " to " + Selection.Text
End If
End If

With Dialogs(wdDialogFileSummaryInfo)
.Title = MyDocTitle
.Execute
End With

Dialogs(wdDialogFileSaveAs).Show
End Sub

Note that this macro only works properly when you are first saving a new
document. If you use it with an existing document (one previously saved
under a different name), the original name is still suggested as the default
in the Save As dialog box, even though the document title is modified.

If you are using Word 6 or Word 95, the following is the WordBasic version
of the macro. It should be saved using the name FileSaveAs, probably in the
same template you use for your letters.

Sub MAIN
MyDocTitle$ = Date$() + " letter"
StartOfDocument
EditFind .Find = "^pDear ", .Direction = 0, .MatchCase = 0,
.WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format = 0, .Wrap = 0,
.FindAllWordForms = 0
If EditFindFound() Then
CharRight 1
EndOfLine 1
CharLeft 2, 1
If Len(Selection$()) > 1 Then
MyDocTitle$ = MyDocTitle$ + " to " + Selection$()
End If
End If

FileSummaryInfo .Title = MyDocTitle$

Dim dlg As FileSaveAs
GetCurValues dlg
On Error Goto ErrHandler
Dialog(dlg)

ErrHandler:
'save only if user didn't click Cancel
If err = 0 Then FileSaveAs dlg
End Sub

Note that either the WordBasic or VBA macros can be assigned to a toolbar
button or a menu option so you can save your documents and name them
automatically.


**********************************************************************
This week WORDTIPS PREMIUM subscribers also read about:

* Slowing Down Mouse Selection
* Understanding Underlines
* Inserting the Edit Time
* Protecting Headers and Footers

To get DOUBLE THE TIPS each week, along with valuable extra benefits,
upgrade to WORDTIPS PREMIUM. For more information, send a blank e-mail to
WTPremium@VitalNews.com or 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.


------------------------------
Specifying a Paper Tray in a Macro
------------------------------
In our office we have multiple printers and also multiple trays in one of
the printers. We have written macros to select the printer that we want to
print to, but we can't get the macro to select which paper tray to use in
the printer. (We use macros so we can do one-click printing without the need
to use the Print dialog box.) When the macro switches to the printer with
multiple trays, it always prints to the same tray that it printed to the
last time, regardless of the tray we select in the macro. How can we specify
a paper tray in the macro?
(Carrie L. Keeler)


------------------------------
Pulling Headers and Footers from Other Files
------------------------------
Using Word 2000 or 2002, is there a way to set up common headers/ footers
(for letterhead) in one or more separate files and then INCLUDE them in a
.DOT document template? (Kind of like a C++ #include
statement.) (Steve Rothkin)


**********************************************************************
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 2002 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: [sathyamurthy@netkracker.com]
To unsubscribe, forward this message to
leave-wordtips-268933P@lists.vitalnews.com

No comments:

Business Line - Markets