Exit workbooks without saving changes or clipboard data

crunchie

New Member
Joined
Mar 10, 2011
Messages
8
Hi,

I am trying to close a workbook in excel using vba. I am copying data from one workbook to another and then attempting to close the original workbook i.e. copying data from "SearchResults" to "VBA_Test_Code".

Here is the code i am using;

Code:
   Workbooks.OpenText Filename:="C:\SearchResults.csv", _
         Origin:=xlMSDOS, StartRow:=1, DataType:=xlFixedWidth,     FieldInfo:=Array( _
         Array(0, 1), Array(24, 1), Array(25, 1), Array(45, 1)),    TrailingMinusNumbers:=True
 
    Cells.Select
    Application.CutCopyMode = False
    Selection.Copy
 
    Windows("VBA_Test_Code").Activate
        Sheets("Results").Select
        ActiveSheet.Paste
 
 
    Workbooks("SearchResults").Close savechanges:=False
 
    ...

I am able to close "SearchResults" without the "save changes" window popping up but the clipboard msgbox pops up as well.

I do not know how much data is going to be in "SearchResults.csv" which is why i am using the "Cells.Select" command.

Is there a command to suppress the clipboard msgbox in vba? If not how would i work around the problem?

Thanks in advance,
Crunchie
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
After your Paste do Application.CutCopyMode=False.
 
Upvote 0
Hi Glenn,

Thank you very much. I was trying to use that piece of code earlier but i was obviuosly using it in the wrong area.


Thanks again.

Crunchie
 
Upvote 0

Forum statistics

Threads
1,213,562
Messages
6,114,326
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top