abroniewski
Registered User.
- Local time
- Yesterday, 16:45
- Joined
- Oct 11, 2011
- Messages
- 14
Hi there!
I am having some trouble manipulating a word document that will be used in my access database.
What I would like is a macro that will go through the entire document and copy/paste highlighted chunks of text (multi sentence) into a new document. I have a macro that I use to find all acronyms and do the same that I am trying to modify for this purpose. I am not sure what how to define my highlighted text criteria to use instead of the "findText" function.
Any help you guru's out there can give is much appreciated. I've been hitting my head on the wall with this problem for a couple days now!!!!
Dim oPar As Paragraph
Dim myCol As New Collection
Dim bView As Boolean
Dim rText As Range
Dim SDoc As Document
Dim TDoc As Document
Set SDoc = ActiveDocument
Set TDoc = Documents.Add
SDoc.Activate
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Text = ""
Do While .Execute(findText:="[A-Z.]{2,}", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rText = Selection.Range
TDoc.Range.InsertAfter rText & vbCr
rText.Collapse wdCollapseEnd
Loop
End With
End With
I am having some trouble manipulating a word document that will be used in my access database.
What I would like is a macro that will go through the entire document and copy/paste highlighted chunks of text (multi sentence) into a new document. I have a macro that I use to find all acronyms and do the same that I am trying to modify for this purpose. I am not sure what how to define my highlighted text criteria to use instead of the "findText" function.
Any help you guru's out there can give is much appreciated. I've been hitting my head on the wall with this problem for a couple days now!!!!
Dim oPar As Paragraph
Dim myCol As New Collection
Dim bView As Boolean
Dim rText As Range
Dim SDoc As Document
Dim TDoc As Document
Set SDoc = ActiveDocument
Set TDoc = Documents.Add
SDoc.Activate
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Text = ""
Do While .Execute(findText:="[A-Z.]{2,}", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set rText = Selection.Range
TDoc.Range.InsertAfter rText & vbCr
rText.Collapse wdCollapseEnd
Loop
End With
End With