Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 02-09-2018, 01:59 PM
macropod's Avatar
macropod macropod is offline Move Selection to the next Column on a Page (Not a table) Windows 7 64bit Move Selection to the next Column on a Page (Not a table) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,514
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

IMHO, this would be a lot simpler if you used Styles for the formatting. As far as I can tell, too, you don't need any complicated arrays. Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long, StrTmp As String: Const StrAcc As String = "m7#b"
On Error Resume Next
With ActiveDocument
  .Styles.Add "Chord", wdStyleTypeParagraph 'wdStyleTypeCharacter
  .Styles("Chord").Font.ColorIndex = wdBlue
End With
On Error GoTo 0
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "<[A-F][m7#b ^13]"
    .Replacement.Text = ""
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If .Paragraphs(1).Style = "Chord" Then
      .End = .Paragraphs(1).Range.End
    Else
      StrTmp = Split(.Paragraphs(1).Range.Text, vbCr)(0)
      For i = 1 To Len(StrAcc)
        StrTmp = Replace(StrTmp, Mid(StrAcc, i, 1), "")
      Next
      For i = 1 To 7
        StrTmp = Replace(StrTmp, Chr(64 + i), "")
      Next
      StrTmp = Trim(StrTmp)
      If StrTmp = "" Then .Paragraphs(1).Style = "Chord"
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "\[[!\[]@\]"
    .Replacement.Text = ""
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
      Select Case .Text
        Case "[Chorus]": .HighlightColorIndex = wdYellow: .Style = wdStyleStrong
        Case "[Verse]": .HighlightColorIndex = wdNoHighlight: .Font.Reset
        Case "[Bridge]": .HighlightColorIndex = wdBrightGreen: .Style = wdStyleStrong
      End Select
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Move Selection to the next Column on a Page (Not a table) Insert Table To Multi Column Page mertdogan Word Tables 2 08-03-2017 03:46 PM
Move Selection to the next Column on a Page (Not a table) Center a table column on page Mutak94 Word Tables 1 09-12-2014 02:52 PM
Move Selection to the next Column on a Page (Not a table) Selection of all Text for a specific page in word is spanning selection across pages ramsgarla Word VBA 9 12-05-2012 03:23 AM
Columns. How to move the left column so it's to the right of the 'right' column ? Vit Word 9 11-21-2012 12:57 PM
Move Selection to the next Column on a Page (Not a table) Long, 3 Column Table - Can I make Fit Into Page Columns? Rigwald Word Tables 9 08-07-2012 08:14 PM

Other Forums: Access Forums

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