Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving Files
Hi,
I need to be able to save my excel file into a text file which is Tab delimited and name the file in another way than the usual <Name.txt I am trying to save as the filename.date.time The filename will always be the same, but the date and time will be whatever the date and time is when the macro is run example JezLisle.060323.093500 How is this possible???? Jez |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving Files
This should do it (remember to type the correct path into it):
Sub SaveTab() Dim myPath As String Dim myFile As String Dim myDot As Integer myPath = "[your file path\]" myFile = ActiveWorkbook.Name myDot = InStr(myFile, ".") - 1 If myDot < -1 Then myFile = Left(myFile, myDot) End If myFile = myFile & "." & Format(Date, "yymmdd") & "." & Format(Time, "hhmmss") ActiveWorkbook.SaveAs Filename:=myPath & myFile, FileFormat _ :=xlText, CreateBackup:=False End Sub "Jez" wrote: Hi, I need to be able to save my excel file into a text file which is Tab delimited and name the file in another way than the usual <Name.txt I am trying to save as the filename.date.time The filename will always be the same, but the date and time will be whatever the date and time is when the macro is run example JezLisle.060323.093500 How is this possible???? Jez |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving Files
Martin,
Thanks for the code. It works a treat :-) one question though as it only puts the time and date as the filename. On your coding you wrote myFile = ActiveWorkbook.Name Is that where I put the filename of this file? As I changed ActiveWorkbook.Name to JezLisle. This is how I want the file to look JezLisle.060323.093500 but I got .060323.093500 Or if myfile should be Activeworkbook.Name how can I have JezLisle before the .060323.093500 Thanks, Jez. "Martin" wrote: This should do it (remember to type the correct path into it): Sub SaveTab() Dim myPath As String Dim myFile As String Dim myDot As Integer myPath = "[your file path\]" myFile = ActiveWorkbook.Name myDot = InStr(myFile, ".") - 1 If myDot < -1 Then myFile = Left(myFile, myDot) End If myFile = myFile & "." & Format(Date, "yymmdd") & "." & Format(Time, "hhmmss") ActiveWorkbook.SaveAs Filename:=myPath & myFile, FileFormat _ :=xlText, CreateBackup:=False End Sub "Jez" wrote: Hi, I need to be able to save my excel file into a text file which is Tab delimited and name the file in another way than the usual <Name.txt I am trying to save as the filename.date.time The filename will always be the same, but the date and time will be whatever the date and time is when the macro is run example JezLisle.060323.093500 How is this possible???? Jez |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Saving Files
Jez-
not sure if you are still monitoring for replies, but just in case- JezLisle (without quotes) is probably being seen as a variable, and unless you assign a value to it, it will be blank. Try putting quotes around it to make is a string, e.g. myfile = "JezLisle" and I think it will append as desired. HTH, Keith "Jez" wrote in message ... Martin, Thanks for the code. It works a treat :-) one question though as it only puts the time and date as the filename. On your coding you wrote myFile = ActiveWorkbook.Name Is that where I put the filename of this file? As I changed ActiveWorkbook.Name to JezLisle. This is how I want the file to look JezLisle.060323.093500 but I got .060323.093500 Or if myfile should be Activeworkbook.Name how can I have JezLisle before the .060323.093500 Thanks, Jez. "Martin" wrote: This should do it (remember to type the correct path into it): Sub SaveTab() Dim myPath As String Dim myFile As String Dim myDot As Integer myPath = "[your file path\]" myFile = ActiveWorkbook.Name myDot = InStr(myFile, ".") - 1 If myDot < -1 Then myFile = Left(myFile, myDot) End If myFile = myFile & "." & Format(Date, "yymmdd") & "." & Format(Time, "hhmmss") ActiveWorkbook.SaveAs Filename:=myPath & myFile, FileFormat _ :=xlText, CreateBackup:=False End Sub "Jez" wrote: Hi, I need to be able to save my excel file into a text file which is Tab delimited and name the file in another way than the usual <Name.txt I am trying to save as the filename.date.time The filename will always be the same, but the date and time will be whatever the date and time is when the macro is run example JezLisle.060323.093500 How is this possible???? Jez |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving files | Excel Discussion (Misc queries) | |||
Saving files | Excel Discussion (Misc queries) | |||
Help - saving files | Excel Worksheet Functions | |||
Closing files and saving files | Excel Worksheet Functions | |||
Saving csv files | Excel Discussion (Misc queries) |