![]() |
|
|
|
#1
|
|||
|
|||
|
I found this code which will show me everything in the word document found between parenthesis. It shows in the Msgbox, but instead I would like to see the contents at the end of my document. Code:
Sub FindInsideParanthesis()
Dim myrange
Set myrange = Application.ActiveDocument.Content
Dim myFind
Set myFind = myrange.Find
While (myFind.Execute(FindText:="\(*\)", MatchWildcards:=True))
'Process your tag here
MsgBox (myrange.Text)
Wend
End Sub
|
|
#2
|
||||
|
||||
|
Try:
Code:
Sub FindInsideParanthesis()
Dim StrOut As String
With ActiveDocument
With .Range
With .Find
.Text = "\(*\)"
.MatchWildcards = True
.Execute
End With
Do While .Find.Found = True
'The next two lines exclude the start/end characters from what gets processed
.Start = .Start + 1
.End = .End - 1
StrOut = StrOut & vbCr & .Text
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
.Range.InsertAfter StrOut
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thank you Paul. This works great.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Font changes when I copy/paste one document into another | RobertWA | Word | 3 | 03-25-2019 06:13 AM |
| Is it possible to copy & paste Table of Contents out of one document into another? | mikey386 | Word | 4 | 12-18-2014 08:45 AM |
Problem with saving document after paste some contents from another document
|
expert4knowledge | Word | 3 | 11-26-2013 03:53 AM |
| copy from web and paste in a word document : no images are shown | Ron Wolpa | Word | 5 | 09-11-2013 02:16 AM |
| Copy the contents of a dcoument and paste it several times in a new document | Gerjanst | Word VBA | 0 | 06-30-2010 12:51 PM |