![]() |
#3
|
||||
|
||||
![]()
While Paul is correct, if you are copying the content of the named document into the active document then the following will do that. You don't have to use the clipboard (though you could).
Code:
Dim oDoc As Document Dim oSource As Document Dim oRng As Range Set oDoc = ActiveDocument Set oSource = Documents.Open(Filename:= _ "X:\sconner\CCD Damage Mechanisms\Mechanisms\Underdeposit Corrosion.docx", _ ConfirmConversions:=False, ReadOnly:=False, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ wdOpenFormatAuto, XMLTransform:="") Set oRng = oDoc.Range With oRng.Find Do While .Execute(FindText:="(NEXT MECH)") oRng.FormattedText = oSource.Range.FormattedText oRng.Collapse 0 Loop End With oSource.Close 0
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
find and replace, userforms, word vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Finding varying text in an MS Word file | sergiodcq | Word | 1 | 07-08-2014 03:12 AM |
Copied shape/text box pastes as an image in Word | spectator | Word | 0 | 06-04-2014 08:45 AM |
![]() |
Adriano | Word VBA | 10 | 03-17-2013 07:08 PM |
Underlined copied text box | LarryStroup | PowerPoint | 0 | 09-30-2011 11:22 AM |
PP Slide copied text is underlined | LarryStroup | PowerPoint | 0 | 05-20-2011 11:16 AM |