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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to control SAVE AS & ALREADY EXISTS msgs 1

Status
Not open for further replies.

cramd

Programmer
Mar 28, 2001
214
US
I have a .csv file that is processed with an excel macro, the file comes in as .csv, the macro moves the text to columns, and then I am trying to save the file still as .csv. I cannot seem to find a way to save the file without receiving the SAVE AS message box, and then followed by "FILE ALREADY EXISTS..." this is the code that I have tried, but does not seem to help, suggestions would be greatly appreciated!
Columns("A:A").Select
Application.DisplayAlerts = False
Selection.TextToColumns Destination:=Range("A1"),

PROCESS MY TEXT TO COLUMNS HERE

ActiveWorkbook.Save
ActiveWorkbook.Close savechanges:=True
Application.DisplayAlerts = True

Diane
 
Try using activeworkbook.saveas, with the proper parameters. That gives you more control over the saving process.
for example

activeworkbook.saveas activeworkbook.name, xlCSV

Rob
[flowerface]
 
Rob,
Thanks for the tip, I finally figured this out using activesheet. The activeworkbook.saveas was still bringing up the message box - thought it may have something to do because I'm still saving as a .csv file(??).

Diane
 
Still puzzled why the saveas approach wouldn't work - I do it all the time. I just tried to reproduce the messagebox behavior, unsuccessfully. Just out of curiosity, how did you get around it?
Rob
[flowerface]
 
Probably this is something I can think off hand. Whenever you use a *.csv file, you get only a worksheet of data and NOT a workbook with different sheets. If you have noticed you shall see the filename as the sheet name also. Probably this is why you are able to save the file if you use activesheet instead of workbook statement.

Ram P
 
I am convinced that it is because I am working with a ".csv" file. While testing, I save the .csv file, but I get two messages, one to replace the existing .csv file, and the other message refers to "compatible features", I choose yes to both. So I finally discovered, by setting displayalerts = false, and then putting my save statement twice, the macro performs perfect.
Diane
 
Excel can drive you up the wall, but the good thing is, there's usually a workaround ;-)
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top