![]() |
#1
|
||||
|
||||
![]()
I wrote a little macro to switch between Outline and Normal view and to set the Outline level. I use it to allow me to move heading sections around using the Alt+Shift+Up/Down Arrow keyboard shortcuts.
The problem that I am having is that sometimes (but not always), after using the macro to move a section, the tab key changes the style setting. If the paragraph has the Normal style, the tab key (anywhere in the paragraph) will change it to the Heading 4 style. If it is already a heading style, it changes the level. It's driving me crazy. If I save the document and reopen it, the tab key behaves normally. If I just do something else in the document, the tab key will eventually stop misbehaving. The macro works great and has for quite awhile. I have it assigned to the Alt+o keyboard shortcut. To use it, I position go to the heading of the section I want to move and invoke the macro (Alt+o). If I am in Normal view, the macro switches to Outline view and changes the outline level to the heading level of that line. I can then move the entire section. When I am done, I invoke the macro again. Seeing that I am in Outline view, the macro sets the outline level to "All" and switches back to Normal view. Here's the code: Code:
Sub MyOutlineLevel() Dim DocLayout 'The document layout (view) Dim ParOutline 'The paragraph outline level (1-9 + 10 (=Bodytext)) DocLayout = ActiveWindow.View ParOutline = Selection.Paragraphs(1).OutlineLevel Select Case DocLayout 'Check the layout (view) Case wdNormalView, wdPrintView 'If Normal or Page (print) view, If ParOutline = 10 Then 'If BodyText paragraph, Exit Sub 'Do nothing Else 'Else, must be a heading ActiveWindow.View.ShowHeading ParOutline 'Show headings only up to that level End If ActiveWindow.View.Type = wdOutlineView 'And switch to Outline view Case wdOutlineView 'If Outline view, ActiveWindow.View.ShowAllHeadings 'Show everything ActiveWindow.View.Type = wdNormalView 'And switch back to Normal view Case Else 'For any other view, Exit Sub 'NOP End Select End Sub ![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
gundas | Word VBA | 3 | 04-02-2013 06:20 AM |
Change single character in PPT to another font macro | rtwwpad | PowerPoint | 1 | 01-19-2013 05:08 PM |
![]() |
ubns | Word VBA | 44 | 09-04-2012 08:17 PM |
Change the leading of a character style??? | Char t | Word | 1 | 11-05-2011 01:18 PM |
Character style stripped while applying paragraph style | sams_gates | Word | 0 | 08-29-2009 02:03 AM |