View Single Post
 
Old 03-28-2016, 06:02 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I don't want my eyes to start bleeding so I am not going to try to read your code.

"Background is I want it to look for
<italics> and <italics/> format in between and then delete them
<bold> and <bold/> format in between and then delete them
<indent> and <indent/> format indentation in between then delete them"


Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim arrTerms() As String
Dim oRng As Range
Dim lngIndex As Long
  arrTerms = Split("(\<italics\>)(*)(\<italics/\>)|(\<bold\>)(*)(\<bold/\>)|(\<indent\>)(*)(\<indent/\>)", "|")
  For lngIndex = 0 To UBound(arrTerms)
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .Text = arrTerms(lngIndex)
      .MatchWildcards = True
      Select Case lngIndex
        Case 0: .Replacement.Font.Italic = True
        Case 1: .Replacement.Font.Bold = True
        Case 2: .Replacement.ParagraphFormat.LeftIndent = 72
      End Select
      .Replacement.Text = "\2"
      .Execute Replace:=wdReplaceAll
   End With
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote