+ Reply to Thread
Results 1 to 4 of 4

Saving Files

  1. #1
    Jez
    Guest

    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. #2
    Martin
    Guest

    RE: 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. #3
    Jez
    Guest

    RE: 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. #4
    KR
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1