View Single Post
 
Old 09-14-2012, 03:06 PM
marceepoo marceepoo is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2012
Posts: 22
marceepoo is on a distinguished road
Default Find & selected paras with highlighted text & copy to clipboard

I am trying to make a macro that will find all paragraphs containing highlighted text, and copy those paragraphs to the windows clipboard - preferably as a group, but if that's difficult, then one by one.

Below is the code from my last failed attempt, before I broke down and decided to request help

Any suggestiions would be much appreciated.

Marc
Code:
Sub subSeveralFailedAttemps()
'
' Changes all bold formatting in the open document named Example.doc to italic formatting.
' http://www.java2s.com/Code/VBA-Excel...formatting.htm
'
Dim strActiveDocFullName As String
Dim strActiveDocName As String
ActiveDocument.ActiveWindow.SetFocus
strActiveDocFullName = ActiveDocument.FullName
strActiveDocName = ActiveDocument.Name
Dim objDoc As Document
Set objDoc = ActiveDocument
Dim objRange As Range
Set objRange = objDoc.Range
Dim intPosition As Long
objRange.Find.Highlight = True
objRange.Find.Forward = True
Do While objRange.Find.Execute
 If objRange.HighlightColorIndex = wdYellow Then
  objRange.Expand Unit:=wdParagraph
  objRange.Copy
 End If
 intPosition = objRange.End
 objRange.Start = intPosition
Loop ' Do While objRange.Find.Execute
' With Documents(strActiveDocName).Content.Find
' .ClearFormatting
' .Highlight = True
' With .Replacement
' .Highlight = True
' End With
' .Execute FindText:="", ReplaceWith:="", _
' Format:=True, Replace:=wdReplaceAll
' If .Found = True Then
' .Parent.Expand Unit:=wdParagraph
' .Parent.Copy
' .Parent.Font.Bold = False
' End If
' End With
'
End Sub ' subSeveralFailedAttemps()

Last edited by macropod; 09-14-2012 at 08:16 PM. Reason: Added code tags & formatting
Reply With Quote