View Single Post
 
Old 12-08-2011, 05:06 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
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

Hi Powerdrum,

Try:
Code:
Sub Demo()
Dim MyData As DataObject, strClip As String, i As Long
Set MyData = New DataObject
With ActiveDocument.Content
  With .Find
    .ClearFormatting
    .Text = ""
    With .Font
      .SmallCaps = False
      .AllCaps = True
    End With
    With .Replacement
      .Text = ""
      .ClearFormatting
    End With
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    .Copy
    MyData.GetFromClipboard
    .Text = MyData.GetText
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
  With .Find
    .Wrap = wdFindContinue
    With .Replacement.Font
      .SmallCaps = False
      .AllCaps = False
    End With
    .Execute Replace:=wdReplaceAll
  End With
End With
End Sub
Note: You'll need to add a reference to the MS Forms object library.

Alternatively, you might prefer this simplified version, which doesn't need a reference to the MS Forms object library:
Code:
Sub Demo()
With ActiveDocument.Content
  With .Find
    .ClearFormatting
    .Text = ""
    With .Font
      .SmallCaps = False
      .AllCaps = True
    End With
    With .Replacement
      .Text = ""
      .ClearFormatting
    End With
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    .Cut
    .PasteSpecial DataType:=wdPasteText
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote