Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Newbie question re: selection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent B. - 30 Mar 2005 00:44 GMT
Once a selection has been set,

selection.wholestory

the text of the document is completely highlighted.

I perform a selection.copy and paste that into a new document.

How does one clear the selection in the original document programatically?

Thanks in advance,

Brent
Jezebel - 30 Mar 2005 02:55 GMT
The short answer is to select something else -- there is always *something*
selected.

However a better approach to coding is not to use the Selection at all,
except for direct interaction with the user. The Selection is just a special
case of Range object, and in code it is easier and quicker to work directly
with the Range objects themselves. To copy the body of a document, you can
use

ActiveDocument.Content.Copy

or, equivalently,

ActiveDocument.StoryRanges(wdMainTextStory).Copy

> Once a selection has been set,
>
[quoted text clipped - 9 lines]
>
> Brent
Cindy M  -WordMVP- - 30 Mar 2005 11:07 GMT
Hi Jezebel,

One exception to this very sound advice is when copying a document. If you use
Selection, it will copy the last paragraph mark, including all the section
formatting (margins, etc.) Doing the same with the Range object does NOT
include the section information, so the result will be different :-) (Had my
face rubbed in this a few years ago by someone in the end-user NGs <g>)

> The short answer is to select something else -- there is always *something*
> selected.
[quoted text clipped - 4 lines]
> with the Range objects themselves. To copy the body of a document, you can
> use

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Abeness - 30 Mar 2005 16:44 GMT
Cindy M -WordMVP- wrote:
> One exception to this very sound advice is when copying a document. If you use
> Selection, it will copy the last paragraph mark, including all the section
> formatting (margins, etc.) Doing the same with the Range object does NOT
> include the section information, so the result will be different :-)

Excellent tip, thanks, Cindy.
Cindy M  -WordMVP- - 30 Mar 2005 11:07 GMT
Hi Brent,

> How does one clear the selection in the original document programatically?

Selection.Collapse

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
Brent B. - 31 Mar 2005 20:29 GMT
Thanks for the feed back. It works perfectly. Any suggestions on where I can
learn more about Word's vba objects and their functionality?

Brent

> Hi Brent,
>
[quoted text clipped - 9 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Jezebel - 31 Mar 2005 22:51 GMT
The object browser is a good place to start. Then the Help files and a lot
of experimenting.

> Thanks for the feed back. It works perfectly. Any suggestions on where I
> can
[quoted text clipped - 16 lines]
>> This reply is posted in the Newsgroup; please post any follow question or
>> reply in the newsgroup and not by e-mail :-)

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.