![]() |
#4
|
||||
|
||||
![]()
I would approach this task from a different direction.
Firstly, if you have control of the receiving file PRIOR to introducing the other content, add a couple of aliases to the heading styles so that the conversion of Epic Title and Main Topic to headings happens automatically as you paste. Add an alias to Heading 3 by modifying the style for Heading 3 so its name is "Heading 3,Epic Title". Do the same for Heading 1 so its name becomes "Heading 1,Main Topic". Note: You can't add an alias if that style name already exists in the document so it has to happen BEFORE pasting in the content from the other source. But once it is done, anything that was styled with either Heading 3 OR Epic Title will paste into the document as Heading 3. So then, all that remains is the question you posted about. I would rewrite that part of the macro along the following lines. Code:
Sub ChangeActiveDocument() Dim aRng As Range, iHeadStyleID As Integer For iHeadStyleID = -4 To -2 '-4=wdStyleHeading3, -2=wdStyleHeading1 Set aRng = ActiveDocument.Range With aRng.Find .ClearFormatting .Style = iHeadStyleID .Wrap = wdFindStop .Forward = True .Text = "" Do While .Execute aRng.ParagraphFormat.Reset aRng.Font.Reset Loop End With Next End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Thefirstfish` | Word VBA | 5 | 04-06-2017 07:18 PM |
MACRO in infinite loop when it encounters user defined figure label | photoval | Word VBA | 3 | 02-02-2016 08:26 PM |
Outlook 2013 - caught in an infinite loop on startup | borderfox | Outlook | 0 | 07-26-2015 01:40 PM |
![]() |
Adriano | Word VBA | 10 | 03-17-2013 07:08 PM |
'Infinite Loop' error with Infopath 2010 | Debbie25 | Misc | 2 | 05-18-2011 08:38 AM |