ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving Files (https://www.excelbanter.com/excel-programming/356877-saving-files.html)

Jez[_7_]

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


Martin

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


Jez[_7_]

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


KR

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





All times are GMT +1. The time now is 01:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com