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 2007

Tip: Looking for answers? Try searching our database.

Copy all parenthetical expressions at the end of the document (incl. Fields)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 23 Aug 2007 09:39 GMT
Dear Experts: Below macro is supposed to copy all parenthetical
expressions at the end of the document. It is running fine with the
exception that ...
... parenthetical expressions within a table causes it to fall into an
endless loop

A SECOND macro similar to the one below should copy all FIELD
EXPRESSIONS, such as user-defined REF-Fields (enclosed in brackets) at
the end of the document. IF I have Word display all the field codes
(Alt + F9) and then adjust below macro to search for ^d, all the field
codes as plain text are copied to the end of the document (not the
field results). I would like Word to make an exact copy of the
parenthetical field expressions and copy them at the end of the
document. Is this feasable?

Could anybody please tell me how to adjust the code ?
Help is appreciated. Thank you very much in advance.

Regards, Andreas

Sub CopyBracketExpressionsAtEndOfDocument()
'Copy all parenthetical expressions at the end of the document.
Regrettably this code falls into an endless loop when it hits
parenthetical expressions in Tables.
   Dim rng As Range
   Dim rngEnd As Long
   Set rng = ActiveDocument.Range
   rngEnd = ActiveDocument.Range.End
   With rng.Find
       .Text = "\([!\)]@\)"

'or "^d" for Fields (Match Wildcards = False). Regrettably only the
field codes as plain text are copied
' to the end of the document, not the field results. But the latter is
what I would like to occur.

       .MatchWildcards = True
       Do While .Execute() ', Wrap:=wdFindStop)
           rng.MoveStart wdCharacter, 1
           rng.MoveEnd wdCharacter, -1
           rng.Copy

           ActiveDocument.Bookmarks("\EndOfDoc").Range.Paste
           ActiveDocument.Bookmarks("\EndOfDoc").Range.InsertAfter
vbCr
           rng.Collapse wdCollapseEnd
           rng.End = rngEnd
       Loop
   End With
End Sub
Russ - 23 Aug 2007 10:48 GMT
See some info below:

> Dear Experts: Below macro is supposed to copy all parenthetical
> expressions at the end of the document. It is running fine with the
[quoted text clipped - 31 lines]
> field codes as plain text are copied
> ' to the end of the document, not the field results.

Look up in Word VBA help:
TextRetrievalMode Object
ShowFieldCodes Property

> But the latter is
> what I would like to occur.
[quoted text clipped - 9 lines]
> vbCr
>             rng.Collapse wdCollapseEnd
             rng.MoveStart wdCharacter, 1 'go past the ")"
>             rng.End = rngEnd
>         Loop
>     End With
> End Sub

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

andreas - 27 Aug 2007 21:17 GMT
> See some info below:
>
[quoted text clipped - 65 lines]
>
> - Zitierten Text anzeigen -

Russ,

thank you for your help.  It is working. Fine. Thank you. Regards,
Andreas
 
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.