Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2010, 10:01 PM
my_vine_figtree my_vine_figtree is offline Reverse order of headings throughout Word Windows Vista Reverse order of headings throughout Word Office 2007
Novice
Reverse order of headings throughout Word
 
Join Date: Aug 2010
Posts: 2
my_vine_figtree is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 08-17-2010, 01:46 AM
my_vine_figtree my_vine_figtree is offline Reverse order of headings throughout Word Windows Vista Reverse order of headings throughout Word Office 2007
Novice
Reverse order of headings throughout Word
 
Join Date: Aug 2010
Posts: 2
my_vine_figtree is on a distinguished road
Default 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
Reply With Quote
Reply

Tags
headings, order, reverse

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inbox Account Order pmokover Outlook 0 08-04-2010 09:34 PM
Office 2007 Ribbon Change Cannot Reverse Russ Office 0 04-29-2010 01:59 AM
Reverse order of headings throughout Word Reversing Text Order weemikey Word 4 08-05-2009 11:10 AM
Reverse order of headings throughout Word Order of Service sparky3883 Word 1 11-17-2008 11:11 PM
sub headings mahound Word 2 08-20-2008 12:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft