Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-20-2014, 04:09 PM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Tab character causes style change to Heading 4 after macro Windows XP Tab character causes style change to Heading 4 after macro Office 2007
Competent Performer
Tab character causes style change to Heading 4 after macro
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default Tab character causes style change to Heading 4 after macro

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
HELP!!!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab character causes style change to Heading 4 after macro Macro to change style name with " in it 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
Tab character causes style change to Heading 4 after macro Macro to replace one specific heading style with another 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:19 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