Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2019, 03:52 PM
jeffreybrown jeffreybrown is offline Copy contents between parenthesis and paste to end of document Windows Vista Copy contents between parenthesis and paste to end of document Office 2007
Expert
Copy contents between parenthesis and paste to end of document
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default Copy contents between parenthesis and paste to end of document

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

Reply With Quote
  #2  
Old 04-23-2019, 05:14 PM
macropod's Avatar
macropod macropod is offline Copy contents between parenthesis and paste to end of document Windows 7 64bit Copy contents between parenthesis and paste to end of document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

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]
Reply With Quote
  #3  
Old 04-23-2019, 07:02 PM
jeffreybrown jeffreybrown is offline Copy contents between parenthesis and paste to end of document Windows Vista Copy contents between parenthesis and paste to end of document Office 2007
Expert
Copy contents between parenthesis and paste to end of document
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thank you Paul. This works great.
Reply With Quote
Reply



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
Copy contents between parenthesis and paste to end of document 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft