Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-18-2014, 01:32 AM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Macro to toggle outline level Windows XP Macro to toggle outline level Office 2007
Competent Performer
Macro to toggle outline level
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default Macro to toggle outline level

I need a macro to toggle the document outline level so I can more easily move document sections around. The macro would query the document layout and the paragraph outline level.

Here's the logic:

If the document is in Normal (or Page) view and the cursor is on a heading, the macro would switch to outline view and set the document outline view level to the paragraph outline level so that it could be moved up or down amongst its peers using the Alt+Shift+Up/Down shortcut.

If the document is in Outline view, the macro would set the document outline view to "All" and switch back to Normal layout.

For any other combination, the macro would do nothing.

Here's the code, which seems to work. Does anyone have any comments:

Code:
Sub MyOutlineLevel()

Dim DocLayout
Dim ParOutline

DocLayout = ActiveWindow.View
ParOutline = Selection.Paragraphs(1).OutlineLevel

Select Case DocLayout
  Case wdNormalView, wdPrintView
    If ParOutline = 10 Then
      Exit Sub
    Else
      ActiveWindow.View.ShowHeading ParOutline
    End If
    ActiveWindow.View.Type = wdOutlineView
  Case wdOutlineView
    ActiveWindow.View.ShowAllHeadings
    ActiveWindow.View.Type = wdNormalView
  Case Else
    Exit Sub
End Select

End Sub

Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to toggle outline level Querying the paragraph outline level Jennifer Murphy Word VBA 1 01-18-2014 01:20 AM
Macro to toggle outline level Paragraph Outline level changes bburns Word 10 07-16-2013 02:34 AM
Macro to toggle outline level Jennifer Murphy Word VBA 0 07-08-2013 08:20 AM
Macro to toggle outline level How to have the words existing in the same Outline Level to be in the Table of Conten Jamal NUMAN Word 1 04-15-2011 06:26 PM
Outline level to Body Text dariober Word 0 08-23-2010 02:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:17 AM.


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