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 / August 2006

Tip: Looking for answers? Try searching our database.

Reverse large files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nomey - 24 Aug 2006 08:50 GMT
Dear all,

Can someone explain why the following code doesn't invert a selection of 60,000 words. Only a small part at the end of the doc is inverted.

Sub ReverseSelection02()
Dim strA As String
   If Selection.Type = wdNoSelection Then
   MsgBox ("There is no selection.")
   Else
   strA = StrReverse(Selection)
   Selection.TypeText (strA)
   End If
End Sub

I'm asking this because I would like to invert a large document with occasional italic and bold formatting, as well as small caps. Is there another method to the text of docs like this - preserving character formatting?  Given the file size, it has to be rather quick.

Chau
Nomey
Jezebel - 24 Aug 2006 09:03 GMT
Your method does indeed reverse all the text of a document (on my test,
anyway). But it won't produce the result you want: TypeText works with plain
text only, so this method necessarily discards all formatting; on top of
which it scrambles the document by reversing the CR/LF sequences at the ends
of paragraphs, not to mention the hideous mess it makes of tables.

Perhaps you could explain your objective in a little more detail: do you
really want the last character of the document to become the first
character, the penultimate to become the second, the antepenultimate the
third, and so on? or do you want to reverse the order of characters within
each paragraph? Do you want each character to retain its formatting, or each
character position?

> Dear all,
>
[quoted text clipped - 18 lines]
> Chau
> Nomey
Nomey - 24 Aug 2006 10:05 GMT
Hi Jezebel,

That is exactly what I would like to achieve: to revert the order of characters within a selection, whether that is just a single word, a couple of sentences/paragraphs or all text in a document. And without losing character formatting, such as bold, etcetera.

My Word version is XP 2002.

Kind regards,
Shirley Nomey

> Perhaps you could explain your objective in a little more detail: do you
> really want the last character of the document to become the first
> character, the penultimate to become the second, the antepenultimate the
> third, and so on? or do you want to reverse the order of characters within
> each paragraph? Do you want each character to retain its formatting, or each
> character position?
Jezebel - 24 Aug 2006 11:40 GMT
You still need to explain your needs further. If you start with the string
ABCDE and B is in bold, and you end up with EDCBA, do you want B or D to be
bold? (ie is it the character or the character *position* that retains the
formatting?) What do you want to do about styles and paragraph formatting?

Whatever your spec, this is not going to be easy to program, and it
certainly isn't going to be quick to run. To preserve character formatting,
you're going to have to work character by character; and to avoid scrambling
your document, you're going to have check for things that you don't want to
reverse, like field names, end of table marks, etc.

> Hi Jezebel,
>
[quoted text clipped - 14 lines]
>> within each paragraph? Do you want each character to retain its
>> formatting, or each character position?
Nomey - 25 Aug 2006 10:19 GMT
Hi Hezebel,

If possible, ABCDE with B and D bold, should be EDCBA with B and D bold. The documents on which I want to run the macro don't have paragraph formatting, nor footnotes, fields, tables or any other special feature. I had no idea that would be such a difficult task and such a time consuming routine when I first started to develop my test macro.

For the time being, I would settle for a quick macro that flips an entire text of 60,000 words without keeping the formatting. My test macro seems to *delete* large parts of the document, retaining only a small portion, which is reversed correctly.

How's that possible? Does the StrReverse() function have built-in lrestrictions, like length, not being able to cross hard returns or hard page breaks, or whatever?

Shirley Nomey

> You still need to explain your needs further. If you start with the string
> ABCDE and B is in bold, and you end up with EDCBA, do you want B or D to be
[quoted text clipped - 6 lines]
> your document, you're going to have check for things that you don't want to
> reverse, like field names, end of table marks, etc.
Jezebel - 25 Aug 2006 13:52 GMT
You missed the point of my ABCDE query: if B (only) is bold in the original,
what character should be bold in the reversal - B or D?

As for strReverse failing on your document: no there is no restriction on
length that I'm aware of. My guess is that your document contains some
character sequence which, when reversed, represents a document corruption. I
just tried it on a document of mine that was originally some 35 pages -- I
got the whole lot in reversal, but completely scrambled as a document: a
whole mess of chinese characters appeared, and tables disappeared: the table
character markers must have ended up *somewhere* ...

> Hi Hezebel,
>
[quoted text clipped - 27 lines]
>> that you don't want to reverse, like field names, end of table marks,
>> etc.
Nomey - 28 Aug 2006 13:51 GMT
Ah, I see: B should remain bold in the reversed text.

> You missed the point of my ABCDE query: if B (only) is bold in the original,
> what character should be bold in the reversal - B or D?
[quoted text clipped - 38 lines]
>>> that you don't want to reverse, like field names, end of table marks,
>>> etc.
 
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.