Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2014, 05:26 PM
acfest acfest is offline Word 2013: CollapseHeading with VBA Windows Vista Word 2013: CollapseHeading with VBA Office 2007
Novice
Word 2013: CollapseHeading with VBA
 
Join Date: Jan 2014
Posts: 2
acfest is on a distinguished road
Default Word 2013: CollapseHeading with VBA

I am writing a macro that goes through my document and collapses specific sections of the document. The expand/collapse heading is a new feature in Word 2013. I know how to expand or collapse all headings: (ActiveDocument.ActiveWindow.View.ExpandAllHeading s), but I cannot figure out how to only expand/collapse the selected heading. The manual way is to either right-click -> collapse heading. The keyboard shortcut is Alt+Shift+-. I see CollapseHeading listed under macros->Word Commands, but I don't know how to call this command. I tried to step into the CollapseHeading macro, and tried recording a macro collapsing a heading, but neither showed anything. Any ideas? Please help....thanks
Reply With Quote
  #2  
Old 01-13-2014, 05:53 PM
gmaxey gmaxey is offline Word 2013: CollapseHeading with VBA Windows 7 32bit Word 2013: CollapseHeading with VBA Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

The following collapse the selected paragraph if it is formatted with a built-in heading style:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
If InStr(Selection.Style, "Heading") = 1 Then
  Selection.Paragraphs(1).CollapsedState = True
End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 01-14-2014, 08:44 AM
acfest acfest is offline Word 2013: CollapseHeading with VBA Windows Vista Word 2013: CollapseHeading with VBA Office 2007
Novice
Word 2013: CollapseHeading with VBA
 
Join Date: Jan 2014
Posts: 2
acfest is on a distinguished road
Default

@GMaxey, Thanks!! It worked!
Reply With Quote
Reply

Tags
vba, word 2013

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2013: CollapseHeading with VBA Word 2013: Hyperlinks in word created pdf open in web browser and not acrobat reader slaycock Word 5 03-08-2014 01:04 PM
Word 2013: CollapseHeading with VBA Word 2013 cday Word 4 01-16-2014 11:58 AM
Word 2013: CollapseHeading with VBA Word 2013 vs Word 2010 formatting issue? rhoyt Word 1 12-07-2013 09:40 AM
Are user customizations transferable from Word 2003 to Word 2010 (2013)? New Daddy Word 3 01-14-2013 07:25 AM
Which ODF/ .odt version is word 2010, 2013 preview & eventually 2013 full using? semiotically Word 8 11-08-2012 05:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:15 AM.


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