Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 11th, 2007, 02:00 AM
Registered User
 
Join Date: Jul 2007
Location: , , India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Save a file in CSV format thru Excel VBA macro

hi
i need some help
i have to copy a sheet from my working excel file and paste it in new file and thn save the file as csv (Comma Delimited) file..
while doing so,even though i m saving the file, i m once again prompted by the message "that do you want to save the changes you made.." whereby i have to click yes...

can this be done thru macro directly????????

the code i have written is as under:
where,
Sheet_Name is the shhet i want to paste
filename1 is the name by which i want to save the new file
oldfilename is the existing excel file where the macro is to b written

     Application.Sheets(Sheet_Name).Select
     Application.Sheets(Sheet_Name).Copy
     ActiveWorkbook.SaveAs Filename:=filename1, FileFormat:=xlCSV, _
     CreateBackup:=False
     ActiveWorkbook.Save
     ActiveWindow.Close
     Windows(oldfilename).Activate
  #2 (permalink)  
Old July 11th, 2007, 03:05 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Just Disable the Alerts and proceed.. You will get it

 Application.Sheets(Sheet_Name).Select
     Application.Sheets(Sheet_Name).Copy
Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:=filename1, FileFormat:=xlCSV, _
     CreateBackup:=False
     ActiveWorkbook.Save
     ActiveWindow.Close
     Windows(oldfilename).Activate

Application.DisplayAlerts = True

Cheers
Shasur

http://www.dotnetdud.blogspot.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read CSV file - Save Columns into Rows pintoo BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 August 20th, 2008 09:01 AM
Change excel into csv format Ivanchan Excel VBA 4 July 5th, 2007 02:02 AM
Unable to save Excel with macro on server guptasourav Classic ASP Basics 0 January 17th, 2007 05:21 AM
save as CSV file cdsniti Java Databases 1 December 21st, 2005 07:26 AM
save file in csv, txt format in jsp URGENT ernidhi2003 JSP Basics 1 October 14th, 2004 04:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.