ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   prevent error message (https://www.excelbanter.com/excel-programming/372200-prevent-error-message.html)

Geebee

prevent error message
 
hi,

I have the following:

Workbooks.Open "filename.csv"
DisplayAlerts = False
If Range("A2").Value 0 Then 'file not empty
Range(Range("A2"), Range("O2").End(xlDown)).Select
Range(Range("A2"), Range("O2").End(xlDown)).Copy
Application.ActiveWorkbook.Close savechanges:=False ' No need to save here
End If

But I noticed when the file closes, I get a message:
"There is a large amount of information on the clipboard. Do yo uwant to be
able to paste this information into another program later?"

I need to know how to prevent getting prompted this, and to see WHY I am
prompted?

Thanks in advance,
geebee


Kevin B

prevent error message
 

Put the following line of code before closing the workbook:

Application.CutCopyMode = False

--
Kevin Backmann


"geebee" wrote:

hi,

I have the following:

Workbooks.Open "filename.csv"
DisplayAlerts = False
If Range("A2").Value 0 Then 'file not empty
Range(Range("A2"), Range("O2").End(xlDown)).Select
Range(Range("A2"), Range("O2").End(xlDown)).Copy
Application.ActiveWorkbook.Close savechanges:=False ' No need to save here
End If

But I noticed when the file closes, I get a message:
"There is a large amount of information on the clipboard. Do yo uwant to be
able to paste this information into another program later?"

I need to know how to prevent getting prompted this, and to see WHY I am
prompted?

Thanks in advance,
geebee


Jim Thomlinson

prevent error message
 
You have copied info to the clipboard so when you close the file the system
wants to know if you intend to keep the data. To get around this do something
with the data prior to closing the 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("Sheet1").Range("A2")
End If
.Close savechanges:=False
end with



--
HTH...

Jim Thomlinson


"geebee" wrote:

hi,

I have the following:

Workbooks.Open "filename.csv"
DisplayAlerts = False
If Range("A2").Value 0 Then 'file not empty
Range(Range("A2"), Range("O2").End(xlDown)).Select
Range(Range("A2"), Range("O2").End(xlDown)).Copy
Application.ActiveWorkbook.Close savechanges:=False ' No need to save here
End If

But I noticed when the file closes, I get a message:
"There is a large amount of information on the clipboard. Do yo uwant to be
able to paste this information into another program later?"

I need to know how to prevent getting prompted this, and to see WHY I am
prompted?

Thanks in advance,
geebee



All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com