Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.PasteAndFormat Issue 1

Status
Not open for further replies.

LCJ18786

Programmer
Nov 23, 2011
9
GB
Could someone please tell me how I can paste text using ".PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)" from a variable called copyBody into the range of two bookmarks in Word. I have written code on how I would like it to work -


copyBody = ActiveDocument.Range(ActiveDocument.Bookmarks("Bookmark 1").Range.Start, _
ActiveDocument.Bookmarks("Bookmark 2").Range.End)


With ActiveDocument
Set rng = ActiveDocument.Range(ActiveDocument.Bookmarks("Text").Range.Start, _
ActiveDocument.Bookmarks("EndText").Range.End)
'This is not correct but along the lines of what I need
rng.text = copyBody.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
End With



Any help would be much appreciated!

Louis
 

In order to PASTE using any paste method, you must first COPY some range.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
What about this ?
ActiveDocument.Range(ActiveDocument.Bookmarks("Bookmark 1").Range.Start, _
ActiveDocument.Bookmarks("Bookmark 2").Range.End).Copy
ActiveDocument.Range(ActiveDocument.Bookmarks("Text").Range.Start, _
ActiveDocument.Bookmarks("EndText").Range.End).PasteAndFormat wdFormatSurroundingFormattingWithEmphasis

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV and SkipVought,

@PHV - When I did initially try it that way it did not work.

I worked it out myself in the end.

Thank you both for your input.

Louis

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top