View Single Post
 
Old 07-10-2017, 06:27 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,598
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Add a formatting switch:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/10/2017
Dim oFld As Field
  For Each oFld In ActiveDocument.Fields
    If oFld.Type = 3 Then
      oFld.Select
      If Not InStr(oFld.Code.Text, "\* Lower") > 0 Then
        If MsgBox("Format with lower case?", vbQuestion + vbYesNo, "FORMAT") = vbYes Then
          If InStr(oFld.Code.Text, "\h") > 0 Then
            oFld.Code.Text = Replace(oFld.Code.Text, "\h", "\* Lower \h")
          End If
          oFld.Update
        End If
      Else
        If MsgBox("Format with upper case?", vbQuestion + vbYesNo, "FORMAT") = vbYes Then
          If InStr(oFld.Code.Text, "\h") > 0 Then
            oFld.Code.Text = Replace(oFld.Code.Text, "\* Lower \h", "\h")
          End If
          oFld.Update
        End If
      End If
    End If
  Next
End Sub
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote