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 / July 2005

Tip: Looking for answers? Try searching our database.

Copying text from one section of a document to another??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ML - 03 Jul 2005 23:52 GMT
I need a means in VBA or similar to copy all text from a user entered
section of a document to another section of the same document and preserve
all formatting and text.  Is this possible?
I had been using the STYLEREF for this but the problem is I may have
multiple paragraphs in the section with the given style and it seems
STYLEREF only copies the last paragraph of text.
Doug Robbins - 04 Jul 2005 05:35 GMT
With VBA, you can use Range.FormattedText

For example, if you had a bookmark name "target" where you want the text to
be replicated and that text was selected, you could use

ActiveDocument.Bookmarks("target").Range.FormattedText =
Selection.Range.FormattedText

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I need a means in VBA or similar to copy all text from a user entered
>section of a document to another section of the same document and preserve
>all formatting and text.  Is this possible?
> I had been using the STYLEREF for this but the problem is I may have
> multiple paragraphs in the section with the given style and it seems
> STYLEREF only copies the last paragraph of text.
ML - 04 Jul 2005 11:50 GMT
So the only way would be with a bookmark?
The issue is the user is going to type this text and it may be too easy for
them to delete the bookmark I would think when they start typing.

> With VBA, you can use Range.FormattedText
>
[quoted text clipped - 10 lines]
>> multiple paragraphs in the section with the given style and it seems
>> STYLEREF only copies the last paragraph of text.
Doug Robbins - 04 Jul 2005 13:35 GMT
The bookmark was at the location to which you wanted the text copied, not
the location at which the user would type the text.  The user would have to
select the text that was to be copied.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> So the only way would be with a bookmark?
> The issue is the user is going to type this text and it may be too easy
[quoted text clipped - 14 lines]
>>> multiple paragraphs in the section with the given style and it seems
>>> STYLEREF only copies the last paragraph of text.
ML - 04 Jul 2005 13:50 GMT
Ok thanks.  This needs to be as automated as possible so selecting the text
is not really an option.

> The bookmark was at the location to which you wanted the text copied, not
> the location at which the user would type the text.  The user would have
[quoted text clipped - 18 lines]
>>>> multiple paragraphs in the section with the given style and it seems
>>>> STYLEREF only copies the last paragraph of text.
Jonathan West - 04 Jul 2005 20:42 GMT
Hi ML,

A bookmark isn't necessary. What *is* necessary is a completely unabiguous
means of defining the source and destination locations. if you can do that,
then you can define Range object variables that mark them, and so do the
copy using the FormattedText method.

Before anybody can give you a code sample for that, we need you to see if
you can describe the source and destination locations.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Ok thanks.  This needs to be as automated as possible so selecting the
> text is not really an option.
[quoted text clipped - 21 lines]
>>>>> multiple paragraphs in the section with the given style and it seems
>>>>> STYLEREF only copies the last paragraph of text.
ML - 04 Jul 2005 22:57 GMT
The destination I can mark with anything required as the user does not edit
anything near the location.  The issue is the source which must allow for
user content.  What options are there for marking it that can then be
selected with a range?

> Hi ML,
>
[quoted text clipped - 31 lines]
>>>>>> multiple paragraphs in the section with the given style and it seems
>>>>>> STYLEREF only copies the last paragraph of text.
Jonathan West - 05 Jul 2005 11:55 GMT
> The destination I can mark with anything required as the user does not
> edit anything near the location.  The issue is the source which must allow
> for user content.  What options are there for marking it that can then be
> selected with a range?

Most elements within a document have a Range property. Every Character,
Word, Sentence, Paragraph, Table, Row, Cell has a range. For instance, if
you can define the source text as occupying the first paragraph of the first
cell of the second row of the first table in the document, then we can code
that and do the transfer.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

ML - 05 Jul 2005 22:05 GMT
Well, the section I want to copy will have a specific style used for the
text it encompasses.  There may be other styles within but the start and end
should be the style I want.  Is it possible to select all of this?

>> The destination I can mark with anything required as the user does not
>> edit anything near the location.  The issue is the source which must
[quoted text clipped - 6 lines]
> first cell of the second row of the first table in the document, then we
> can code that and do the transfer.
Thirsty_4_knowledge - 28 Jul 2005 22:39 GMT
I am trying to do the same thing -

My document is split up by each page being a seperate section (to achieve
different headers/footers per page).  I want to dump EVERYTHING from the 2nd
section/page on into the 1st section.  Or would it be easier to just delete
the section breaks automatically somehow...

Thanks for your time!

> Hi ML,
>
[quoted text clipped - 31 lines]
> >>>>> multiple paragraphs in the section with the given style and it seems
> >>>>> STYLEREF only copies the last paragraph of text.
 
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.