Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing CSV File without being prompted to save

Status
Not open for further replies.
Jul 14, 2003
116
CA
I wrote a script to copy data from a series of CSV files in a directory into an excel spreadsheet. When I'm done copying the date I close the CSV files. I am trying to figure out how to close the files without being prompted to save the file. I have tried the following:

importWkbk.Save
importWkbk.Close False

WHich works for regular .xls files but doesn't seem to work for CSV files. ANy ideas?

Thanks...
 
Hi
It might be a pain but...
Code:
With Workbooks("MyCSV.csv")
    .Saved = True
    .Close
End With

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
application.displayalerts = false
importWkbk.Close False
application.displayalerts = true


.....or Loomah's way - dunno if that will work though as it appears to be a default message whether or not you save the file...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
xlbo
Funny you should say that but I tried going down the displayalerts route and it didn't work for me!!

But hey, that's often just me!

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
But as is often the case, the cat may be skinned in an almost endless number of ways.

This takes me back to an earlier life when I was just really starting to get to grips with a little VBA. This is the sort of method I used to close the csv files I used then

Code:
If Workbooks("csv_no_headers.csv").Saved = False Then SendKeys "N"
Workbooks("csv_no_headers.csv").Close

But looking back, it's just silly!

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
LOL - I remember doing stuff like that too

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top