![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 2
|
Hi I want to know if it's possible to auto save a .xls file as a .csv file to a certain directory every time the document is opened?
So it needs to run on open and do a save as and save it as a .csv. Can this be done? Thanks |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Newcastle, UK
Posts: 1,174
|
Quote:
Private Sub Workbook_Open() ThisWorkbook.SaveAs "c:YourFilename", xlCSV End Sub you'll need to change the filename everytime or it will ask you if you want to replace exsiting file. something like: Private Sub Workbook_Open() Sheet2.Range("A1").Value = Sheet2.Range("A1").Value + 1 ThisWorkbook.SaveAs "c:YourFilename" & Sheet2.Range("A1").Value, xlCSV End Sub Hope this starts you off. Also search the Help files for 'SaveAs'.
__________________
"Have a good time......all the time" Ian Mac |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: May 2002
Posts: 2
|
Hi thanks for that it's perfect, is it possible to over right the file each time the document is opened????
What's happening is a script auto opens the .xls document, the document then saves it's self (with your macro) as a .cvs file. There is a feed going into this file constantly and it auto saves it's self every 10 mins. This file will then be ftp'd out of this directory every 20 mins by the same script. The reason it needs to be a .csv is the places it gets ftp'd to can only read it in that format, and obviously the feed won't run into the document in .csv format only .xls format...... Long winded but I'm sure when it works it will work for ever! So the problem I have is if the document is closed and the script opens it the macro will need to over right the file, it's possible I could right it into the script to delete the file after it ftp's but I'd rather not have to go that far!! Thanks for your help.... |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|