Log in

View Full Version : Problem copying from one document to another



sharky12345
06-08-2013, 12:14 PM
I'm trying to copy from 1 active document, open another and then paste to the 2nd document but I can't get this to work.

Can anyone offer some advice please?

Option Explicit
Sub CopyBM9()
Dim Rng As Range, St As Long, Ed As Long
St = ActiveDocument.Bookmarks("Working17").Start
Ed = ActiveDocument.Bookmarks("Working18").End
Set mydoc = ActiveDocument.Path & "\Minute Sheet.doc"
Set Rng = ActiveDocument.Range(Start:=St, End:=Ed)
Rng.Copy

Documents.Open FileName:=ActiveDocument.Path & "\Minute Sheet.doc"
mydoc.Activate
Rng.Paste

End Sub

gmaxey
06-08-2013, 12:24 PM
Basically something like this:

Sub CopyBM9()
Dim oDoc As Word.Document
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
oRng.Copy
Set oDoc = Documents.Add
oDoc.Range.Paste


End Sub

sharky12345
06-08-2013, 12:32 PM
Thank you Greg, that's progress - how can I make sure that it opens the file called 'Minute Sheet' though?

gmaxey
06-08-2013, 01:48 PM
Assuming the activedocument and Minute Sheet are in the same folder:

Sub CopyBM9()
Dim oDoc As Word.Document
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
oRng.Copy
Set oDoc = Documents.Open(ActiveDocument.Path & "\Minute Sheet.doc")
oDoc.Range.Paste
End Sub

sharky12345
06-09-2013, 12:18 AM
Thanks Greg, that's perfect.

xmlld
06-19-2013, 08:01 PM
not work for me .may I have got something wrong.

Aussiebear
06-19-2013, 08:23 PM
not work for me .may I have got something wrong.

What doesn't work? How did you use the code provided and can you be indicate what you were working on at the time as this will be useful information rather than the above statement.

sharky12345
06-20-2013, 01:01 AM
Well it worked for me so I'm all good!