Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 02-15-2023, 12:16 PM
Donfaison Donfaison is offline Loop Until End of Document Windows 10 Loop Until End of Document Office 2016
Novice
 
Join Date: Feb 2023
Posts: 2
Donfaison is on a distinguished road
Default

"Do Until Selection.Range.End = ActiveDocument.Range.End" becomes an infinite loop for me. My code successfully finds wdstyleHeading5 (a title from a journal) and converts the 1st line below it to wdstyleHeading6, the collapses the abstract beneath. This allows me to quickly create an outline and show the first line of the citation (journal & date) when I print. However, once it gets to the end it simply keeps on searching. Any thoughts"
Sub Create_Collapsed_Heading6()
Selection.HomeKey Unit:=wdStory
Do Until Selection.Range.End = ActiveDocument.Range.End
Selection.Find.Style = ActiveDocument.Styles("Heading 5")
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Style = wdStyleHeading6
Selection.Paragraphs(1).CollapsedState = True
Loop
ActiveDocument.PrintOut
End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Until End of Document How to loop once through document PrincessApril Word VBA 4 04-12-2020 06:06 AM
Loop Until End of Document Loop thru document and create bookmarks jeffreybrown Word VBA 3 09-22-2018 06:04 AM
Loop true all opned word document elbartje Word VBA 1 06-12-2017 05:27 PM
VB for Word - Need macro to loop each line in a document NDeane Word VBA 5 12-22-2015 08:12 PM
Loop Until End of Document Loop through files and Copy Table Row and Paste into Different Document spiderman1369 Word VBA 2 10-15-2014 08:30 AM

Other Forums: Access Forums

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