Thread: pasting
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default pasting

When you specify application.cutcopymode = false you remove what you just
copied. It will prevent the error message but it will render the copy
useless. You should paste prior to closing your file... Something like this...

dim wbkCopyFrom as Workbook

set wbkCopyFrom = Workbooks.Open("filename.csv")
with wbkCopyFrom
If .Range("A2").Value 0 Then 'file not empty
.Range(.Range("A2"), .Range("O2").End(xlDown)).Copy _
ThisWorkbook.Sheets("Input").Range("A265")
End If
.Close savechanges:=False
end with

--
HTH...

Jim Thomlinson


"geebee" wrote:

hi,

I am trying to paste copied data from a csv file into another workbook's
"Input" sheet, starting at row 265. Basically, I have the following:

Workbooks.Open "source.csv"
DisplayAlerts = False
If Range("A2").Value 0 Then 'file not empty
Range(Range("A2"), Range("M2").End(xlDown)).Select
Range(Range("A2"), Range("M2").End(xlDown)).Copy
Application.CutCopyMode = True 'prevent the following prompt: "There is a
large amount of information on the clipboard. Do yo uwant to be able to
paste this information into another program later?"
Application.ActiveWorkbook.Close savechanges:=False ' No need to save here
End If

'paste data from csv file, starting at row 265
Sheets("Input").Activate
Range(Range("A265"), Range("M265").End(xlDown)).Select
With ActiveSheet
.Range(.Range("A265"), .Range("M265").End(xlDown)).Copy _
Sheets("Input").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

I am not able to get this to work. Nothing is being pasted. Can someone
tell me why, and how to fix this?

Thanks in advance,
geebee