PC Review


Reply
Thread Tools Rate Thread

Closing workbook open as CSV

 
 
S Shipley
Guest
Posts: n/a
 
      18th Mar 2010
I open a CSV file in Excel, Copy two columns of data, paste the data into
another workbook and then I want to cloes the CSV file without getting a
prompt about saving the data to the clipboard.

I am using Application.ActiveWindow.Close (False) to close the file but I'm
still getting the prompt to save the data. Is there another command I should
use?

Thanks,
Sam
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Mar 2010
First, I don't go through the Windows collection. I just close the workbook.

Dim CSVWkbk as workbook
'other code here

'open the csv file
Workbooks.Open Filename:="somepath\somename.csv"
set csvwkbk = activeworkbook 'the csv that was just opened

'do lots of work
'and close the workbook
csvwkbk.close savechanges:=false

And I don't get that prompt message. (Maybe you're closing the wrong window???)

If this doesn't help, try:

application.displayalerts = false
Application.ActiveWindow.Close False
application.displayalerts = true




S Shipley wrote:
>
> I open a CSV file in Excel, Copy two columns of data, paste the data into
> another workbook and then I want to cloes the CSV file without getting a
> prompt about saving the data to the clipboard.
>
> I am using Application.ActiveWindow.Close (False) to close the file but I'm
> still getting the prompt to save the data. Is there another command I should
> use?
>
> Thanks,
> Sam


--

Dave Peterson
 
Reply With Quote
 
Wouter HM
Guest
Posts: n/a
 
      18th Mar 2010
Hi Sam,

In addition to Dave's first sample:

'open the csv file
Workbooks.Open Filename:="somepath\somename.csv"
set csvwkbk = activeworkbook 'the csv that was just opened


'do lots of work

'mislead the workbook it is saved after changes
csvwkbk.saved = true

'and close the workbook
csvwkbk.close savechanges:=false


HTH,

Wouter
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      18th Mar 2010
I don't recall ever having to mislead excel if I closed without saving changes.

But if it helps the original poster, woohoo!!!

Wouter HM wrote:
>
> Hi Sam,
>
> In addition to Dave's first sample:
>
> 'open the csv file
> Workbooks.Open Filename:="somepath\somename.csv"
> set csvwkbk = activeworkbook 'the csv that was just opened
>
> 'do lots of work
>
> 'mislead the workbook it is saved after changes
> csvwkbk.saved = true
>
> 'and close the workbook
> csvwkbk.close savechanges:=false
>
> HTH,
>
> Wouter


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
projects left open in vba after closing workbook Gary Keramidas Microsoft Excel Programming 4 26th Jul 2009 10:14 AM
how i open another sheet in the same workbook without closing? kamrul Microsoft Excel Misc 1 14th Feb 2009 08:31 AM
Keeping program open even when closing workbook Bob Microsoft Excel Misc 3 25th Apr 2008 07:55 PM
Closing an open workbook =?Utf-8?B?RGFu?= Microsoft Excel Programming 3 16th Aug 2006 08:54 AM
Excel-Can't close 1 open Workbook without closing other open Workb =?Utf-8?B?ZnJhbWluZ2hhbQ==?= Microsoft Excel Misc 1 18th Oct 2004 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 AM.