Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2022, 04:38 PM
Guessed's Avatar
Guessed Guessed is offline Looking for a randomization macro in Word 365 Windows 10 Looking for a randomization macro in Word 365 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This concept appears to work IF a heading is the trigger for each block of pages (ie a paragraph which has an outline level other than body text).
Code:
Sub RandomSortOfChap()
  Dim aPar As Paragraph
  'Add random numbers on headings
  For Each aPar In ActiveDocument.Paragraphs
    If aPar.Range.ParagraphFormat.OutlineLevel <> wdOutlineLevelBodyText Then
      aPar.Range.InsertBefore Left(Rnd(1) * 100000, 4) & vbTab
    End If
  Next aPar
  'Now sort based on the random number
  ActiveWindow.ActivePane.View.Type = wdOutlineView
  ActiveWindow.View.ShowHeading 5     'show five levels of headings
  Selection.Sort FieldNumber:="Paragraphs", SortFieldType:=wdSortFieldAlphanumeric
  ActiveWindow.ActivePane.View.Type = wdPrintView
  'And remove the numbers
  ActiveDocument.Range.Select
  WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
End Sub

__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Word VBA macro] How to open the website [languagetool.org] and check my Word document? citroen Word VBA 0 10-25-2020 05:07 AM
Macro to transfer data from Word to another Word document with bookmark Jovan Yong Word VBA 3 04-17-2018 04:27 AM
Macro to put 1 word of a MS Word file in 1 cell of a Word or Excel Table Singh_Edm Word VBA 6 11-13-2015 08:48 PM
Looking for a randomization macro in Word 365 Macro Question: Need help making a macro to highlight the first word in every sentence LadyAna Word 1 12-06-2014 10:39 PM
Looking for a randomization macro in Word 365 Word 2003 Macro problem running in Word 2010 norwood Word VBA 2 02-03-2014 06:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:50 PM.


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