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 fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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