View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
drinese18 drinese18 is offline
external usenet poster
 
Posts: 59
Default Saving worksheet as a text file

I am trying to create a macro that will save a worksheet as a text file when
I call the macro. So far I got it to save the worksheet as a text file, but I
would like it to save as different files, instead of overwriting one file
over and over. For instance when I edit the file everyday and I save it, I
want it to be saved as a certain name, maybe todays date, the next day I
would like it to save as the date for that day. Does anyone know how to do
this? I recorded a macro below, tell me what you think:

Sub Save_as()


Application.ScreenUpdating = False
Application.DisplayAlerts = False

Sheets("ExportSheet").Select

Dim myPath As String
Dim myFile As String

myPath = ActiveWorkbook.Path & "\"
myFile = "import_file"
myFile = myFile & ".txt"

ActiveWorkbook.SaveAs Filename:=myPath & myFile, FileFormat:=xlText,
CreateBackup:=False

Sheets("Sheet1").Select
Sheets("import_file").Name = "ExportSheet"

Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub