PC Review


Reply
Thread Tools Rate Thread

How to backup Excel using VBA?

 
 
skarkada@gmail.com
Guest
Posts: n/a
 
      10th Jan 2008
I am looking for a "Save As" type functionality without changing the
Excel's current file.

What I am trying to do is to save a snapshot of the current worksheet
in CSV format before my macro's logic begins to execute.
ActiveWorkbook.SaveAs method worked exactly like I wanted, but it
changed the current file in the Excel.

SaveCopyAs method would work fine, but it insists on saving the whole
workbook and also doesn't support changing the format to CSV.

I could read the contents of the worksheet, convert to CSV strings,
open a text file, and write to it. But, if there is a built-in
function, I don't want to reinvent the wheel.

Thank you for your time.
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      10th Jan 2008
see SaveCopyAs in help.

Regards,
Peter T


<(E-Mail Removed)> wrote in message
news:ce61b8fb-88bb-49f0-8b11-(E-Mail Removed)...
> I am looking for a "Save As" type functionality without changing the
> Excel's current file.
>
> What I am trying to do is to save a snapshot of the current worksheet
> in CSV format before my macro's logic begins to execute.
> ActiveWorkbook.SaveAs method worked exactly like I wanted, but it
> changed the current file in the Excel.
>
> SaveCopyAs method would work fine, but it insists on saving the whole
> workbook and also doesn't support changing the format to CSV.
>
> I could read the contents of the worksheet, convert to CSV strings,
> open a text file, and write to it. But, if there is a built-in
> function, I don't want to reinvent the wheel.
>
> Thank you for your time.



 
Reply With Quote
 
skarkada@gmail.com
Guest
Posts: n/a
 
      10th Jan 2008
On Jan 10, 10:30*am, "Peter T" <peter_t@discussions> wrote:
> see SaveCopyAs in help.
>
> Regards,
> Peter T


Peter, thanks for your message. SaveCopyAs wouldn't save as CSV and
wouldn't let me save just the current worksheet. We are on Excel 2003
version.
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      10th Jan 2008
<(E-Mail Removed)> wrote in message
> > see SaveCopyAs in help.


> Peter, thanks for your message. SaveCopyAs wouldn't save as CSV
> and wouldn't let me save just the current worksheet.


Sorry, I didn't read your post carefully before replying.
How about this -

Sub test()
Dim ws As Worksheet

Set ws = ActiveSheet ' change to suit
ws.Copy

Application.DisplayAlerts = False
' code to ensure filename does not already exist
ActiveWorkbook.SaveAs Filename:="C:\CVS_test.csv", FileFormat:=xlCSV
ActiveWorkbook.Close

Application.DisplayAlerts = true
End Sub


Regards,
Peter T


 
Reply With Quote
 
skarkada@gmail.com
Guest
Posts: n/a
 
      10th Jan 2008
Wonderful solution!

Thank you very much for your help.
 
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
Why does Access to Excel export create backup copies of Excel? Erica Microsoft Access External Data 2 15th Apr 2008 02:54 PM
Create new excel files, Save backup of excel file Gil Microsoft Excel Programming 8 9th May 2006 09:40 PM
Backup file for excel NITESH G Microsoft Excel Misc 1 10th Nov 2005 03:53 PM
Excel backup file =?Utf-8?B?QW15?= Microsoft Excel Discussion 2 29th Apr 2005 09:59 PM
Excel File backup Rajkumar Microsoft Excel Discussion 2 20th Apr 2004 11:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:47 AM.