adambensaid
New Member
- Joined
- Feb 22, 2011
- Messages
- 5
Hi,
I have a workbook (wb1) that has code to open a different workbook (wb2), copy the content of the csv file within wb2, close wb2, and paste the content to one of the sheets (Sheet1) in wb1.
The issue that I am having is that when wb2 is being closed, I receive the dreaded clipboard message. Since the paste command is after the close command, I cannot empty the clipboard until I paste the contents.
Also, the Application.EnableEvents = False does not seem to help. Below is a snippet of the code. Unfortunately, I cannot pull the contents from a closed workbook (that I know) since the path can't be hard-coded. I would like the macro to run without prompting the user for anything. Can I:
Let me know if you need additional code. Thanks for your help.
Adam
I have a workbook (wb1) that has code to open a different workbook (wb2), copy the content of the csv file within wb2, close wb2, and paste the content to one of the sheets (Sheet1) in wb1.
The issue that I am having is that when wb2 is being closed, I receive the dreaded clipboard message. Since the paste command is after the close command, I cannot empty the clipboard until I paste the contents.
Code:
Application.CutCopyMode = False
- Somehow suppress the clipboard message
- Paste the contents in wb1, empty the clipboard, then close wb2 (How?)
- Other suggestions
Code:
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.Close savechanges:=False
Application.EnableEvents = False
ThisWorkbook.Activate
Sheets("Sheet1").Activate
Range("A2").Select
ActiveSheet.Paste
Application.EnableEvents = True
Adam