![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
We have text that has the following structure. This uses styles and also cross-referencing (to paragraph numbers).
- numbered style - non-numbered style(s) - numbered style, but includes cross-reference to numbered style (paragraph format) - non-numbered style(s)... Something like this example: 1. Numbered style some non-numbered style(s) 2. Numbered style that cross-references paragraph #1 some non-number styles(s) 3. Numbered style that cross-references paragraph(s) #1 and/or #2 .... In order to get the cross-references, someone has inserted a cross-reference with a reference type of "numbered item" and an "insert reference to" "paragraph number". I want to: a) have someone copy the example text above (from the "active" document) b) have that person put an insertion point after the example text c) open a new document and insert the example text, complete with formatting and cross-referencing intact d) manipulate text in the text of the new document e) copy the manipulated text and paste back into the "active" document, hopefully retaining the styles and the cross-referencing This is the code to do (a), (b), and (c): Code:
Sub Test() ' Prerequisites: copy the formatted text ' Put the insertion point at a paragraph after the copied text, on a blank line ' Declarations Dim selectedText As Range Set selectedText = Selection.Range Dim newDoc As Document ' Add a new document to store the copied text Set newDoc = Documents.Add ' This adds with all the formatting, including cross-referencing newDoc.Content.Paste How do I manipulate the text in newDoc? (All the code I have uses Selection.Find, which does not seem appropriate.) (E.g., this is a simple find and replace: FindTextA and ReplaceWithTextB.) Once I manipulate the text, how do I copy the contents of the (revised) newDoc? Is it possible to copy (and paste) the text complete with the styles and embedded cross-referencing? Note: the styles in newDoc are the same as what is in the active document. So, assuming the example above is used with three numbered styles, the pasted-in text from newDoc would have 4,5,6 based on the same numbered style. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Code on a button to attach a document to my Word Auto fill document is not working on a Mac | reynoldsrjr | Word | 0 | 03-30-2020 04:00 AM |
Single step Word Styles from Source Document through entire Destination document? | xbliss | Word | 6 | 08-27-2016 09:36 PM |
How to save active document to SharePoint document library | Rose roon | Word VBA | 9 | 09-22-2015 10:53 PM |
document styles and some formatting doesn't appear where should when different people view document | Dilbert fan | Word | 1 | 08-23-2015 05:07 AM |
![]() |
Liza | Word | 1 | 11-06-2014 12:44 PM |