LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default copying and pasting to a different xls file in a different dir

Hi Dr Chuck,

apologies for the stupidly late reply, but hey, better late than never, and
hopefully you forgot to cancel the "notify of replies"!!

Certain functions in Excel clear the clipboard of any data held on it.
Examples include clearing a cell, protecting or unprotecting a worksheet etc.

If you do this manually, it works in the same way. Try it! Copy a cell, then
do some random stuff, and see if it's still on the clipboard. I don't have a
list of functions that clear the clipboard, but if it disappears between one
function and the next, then it's a safe bet!

re your earlier code, the action that cleared the clipboard was the "SaveAs"
- any save command will clear the clipboard, even if cancelled. Try copying a
cell, then save or open the save as dialog, and even if you cancel, it'll
still clear the clipboard, and you'll need to copy again before pasting.

HTH, and again, apologies for the 3 months delay in answering!! (*shame*)
DS

"dr chuck" wrote:

just tried your suggestion .. it worked for me.

Is it complicated to explain to me why...

"the Copy you performed earlier has been cleared by
the tasks you're performing between the two"

thanks
--
dr chuck


"DS" wrote:

Hi dr chuck,

As far as I can tell, the Paste is failing because there's nothing on the
clipboard at that point - the Copy you performed earlier has been cleared by
the tasks you're performing between the two.

If you change round to:

Private Sub test2_Click()

Dim s As String, bk As Workbook

s = Range("othermanufact").Value & "-" & Range("lot").Value & "-" &
Format(Range("exp").Value, "mmddyyyy") & ".xls"
Set bk = Workbooks.Add()
bk.SaveAs "C:\Program Files\PanelSelect\panels\" & s


Workbooks.Open Filename:= _
"C:\Program Files\PanelSelect\panels\" & s

ActiveWindow.Visible = True

ThisWorkbook.Activate
Range("C40:E40").Copy

Windows(s).Activate

Sheets("Sheet1").Range("c2").Activate

ActiveSheet.paste

End Sub

Then this should work for you. It's a pretty crude method, but functions.
HTH
DS



"dr chuck" wrote:


the following syntax.. creates the apporpriate file "s" and opens it and
gets me to the correct range. It however will not paste the information that
was selected and copied. It gives me an error every time on
ACTIVESHEET.PASTE. I get "run time error 1004".. paste method of worksheet
class failed.

Private Sub test2_Click()
Range("C40:E40").Select
Selection.Copy

Dim s As String, bk As Workbook

s = Range("othermanufact").Value & "-" & Range("lot").Value & "-" &
Format(Range("exp").Value, "mmddyyyy") & ".xls"
Set bk = Workbooks.Add()
bk.SaveAs "C:\Program Files\PanelSelect\panels\" & s


Workbooks.Open Filename:= _
"C:\Program Files\PanelSelect\panels\" & s

ActiveWindow.Visible = True


Windows(s).Activate

Sheets("Sheet1").Range("c2").Activate

ActiveSheet.paste <===error here every time

End Sub




help
dr chuck



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying and pasting to a different xls file in a different directo dr chuck Excel Programming 0 July 27th 06 04:16 AM
copying from one file pasting in another tim64[_54_] Excel Programming 4 July 8th 05 11:28 PM
Pasting formulas without copying file ref. John Tolman[_2_] Excel Programming 1 July 15th 04 02:31 AM
Copying rows from one file and pasting into a new file Tina Excel Programming 0 August 25th 03 04:34 AM
Copying rows from one file and pasting into a new file Stan Bauer Excel Programming 3 August 24th 03 10:41 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"