![]() |
Reverse order of headings throughout Word
Anyone know of any macro code or way to reverse about 100 headings in a Word 2007 Document?
I want to change the headings (representing by letters) into reverse order so that CCCC 5 6 BBBB 3 4 AAAA 1 2 becomes AAAA 1 2 BBBB 3 4 CCCC 5 6 |
Reverse order of headings throughout Word
I found the code below but it turns
BBBB 3 4 AAAA 1 2 into the following AAAA 2 1 BBBB 4 3 instead of AAAA 1 2 BBBB 3 4 Any ideas? Sub reverseheadings() ' ' reverseheadings Macro ' ' Dim iPara As Long Dim iLastPara As Long Dim doc As Document Dim docNew As Document Dim rng As Range Set doc = ActiveDocument Set docNew = Documents.Add iLastPara = doc.Paragraphs.Count Set paraHeader = docNew.Paragraphs.Add paraHeader.Style = "Heading 1" For iPara = doc.Paragraphs.Count To 1 Step -1 If doc.Paragraphs(iPara).Style = "Heading 1" Then paraHeader.Range = doc.Paragraphs(iPara).Range.Sentences(1) Set paraHeader = docNew.Paragraphs.Add paraHeader.Style = "Heading 1" iLastPara = iPara - 1 End If If doc.Paragraphs(iPara).Style = "Normal" Then Set rng = doc.Paragraphs(iPara).Range rng.Select Selection.Copy Set rng = docNew.Range rng.Collapse wdCollapseEnd rng.Select rng.Paste iLastPara = iPara - 1 End If Next iPara End Sub |
All times are GMT -7. The time now is 07:32 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by
DragonByte SEO (Lite) -
vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft