Word copy paste macro - doc to doc

B

bossmansmith

I have tow word .doc open at once. I would like to place a cursor on a line
of line in doc #1 and prefrom the following macro but cannot fgiure out how
to do doc to doc rather then within a single doc.

macro:
shift-left arrow (to bring cursor to begin of line)
shift-down arrow (to highlight entire line)
ctrl-c (to copy highlighted into clipboard)
switch to doc #2
ctrl-v (to copy from clipbaord)
switch back to doc #1

i can program this to work within a single doc but not access doc#2 at all.

any help would be appreciated.
 
D

Doug Robbins - Word MVP

With two documents open and with the source document as the active document
and the cursor in the line that you want to copy, run the following macro

Dim myrange As Range
Set myrange = Selection.Bookmarks("\line").Range
Application.Windows(2).Activate
ActiveDocument.Range.InsertAfter myrange.FormattedText & vbCr
Application.Windows(1).Activate

You may want to do something other than put a carriage return after each
line - e.g. use vbSpace instead
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top