+ Reply to Thread
Results 1 to 6 of 6

Macro Save File (Unique file name)

Hybrid View

Guest Macro Save File (Unique file... 10-27-2005, 04:05 PM
Guest Re: Macro Save File (Unique... 10-27-2005, 04:05 PM
Guest Re: Macro Save File (Unique... 10-27-2005, 05:05 PM
Guest RE: Macro Save File (Unique... 10-27-2005, 04:05 PM
Guest RE: Macro Save File (Unique... 10-27-2005, 05:05 PM
Guest RE: Macro Save File (Unique... 10-27-2005, 06:05 PM
  1. #1
    SJC
    Guest

    Macro Save File (Unique file name)

    I currently have a code which I have listed below which will save a file when
    the user selects the button. I have some users who will need to save two or
    more files, which directs them to overwrite the file since currently, there
    is no identifier in the file name. The indentifier that I would like to add
    is on another spreadsheet in the same workbook. (Worksheet name:
    Intro--Start Here; cell: G13)

    Does anyone know how I can add this information to the filename so that each
    file saved will have a unique name? Thanks for any suggestions.


    Dim strPath As String
    Dim strFileName As String

    strPath = Application.DefaultFilePath & "\"
    strFileName = "xxx"

    ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False
    ActiveWindow.Close
    Sheets("Intro--Start Here").Select
    MsgBox ("xxx")

    End Sub

  2. #2
    Ron de Bruin
    Guest

    Re: Macro Save File (Unique file name)

    Hi

    In my Mail examples i always use the date and time

    Dim strdate As String
    strdate = Format(Now, "dd-mm-yy h-mm-ss")

    For a example see this one for example
    http://www.rondebruin.nl/mail/folder1/mail2.htm

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "SJC" <SJC@discussions.microsoft.com> wrote in message news:FD490D6A-FDEF-4465-B781-28ADA0077683@microsoft.com...
    >I currently have a code which I have listed below which will save a file when
    > the user selects the button. I have some users who will need to save two or
    > more files, which directs them to overwrite the file since currently, there
    > is no identifier in the file name. The indentifier that I would like to add
    > is on another spreadsheet in the same workbook. (Worksheet name:
    > Intro--Start Here; cell: G13)
    >
    > Does anyone know how I can add this information to the filename so that each
    > file saved will have a unique name? Thanks for any suggestions.
    >
    >
    > Dim strPath As String
    > Dim strFileName As String
    >
    > strPath = Application.DefaultFilePath & "\"
    > strFileName = "xxx"
    >
    > ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    > xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    > , CreateBackup:=False
    > ActiveWindow.Close
    > Sheets("Intro--Start Here").Select
    > MsgBox ("xxx")
    >
    > End Sub




  3. #3
    SJC
    Guest

    Re: Macro Save File (Unique file name)

    Great--thanks for your help.

    "Ron de Bruin" wrote:

    > Hi
    >
    > In my Mail examples i always use the date and time
    >
    > Dim strdate As String
    > strdate = Format(Now, "dd-mm-yy h-mm-ss")
    >
    > For a example see this one for example
    > http://www.rondebruin.nl/mail/folder1/mail2.htm
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "SJC" <SJC@discussions.microsoft.com> wrote in message news:FD490D6A-FDEF-4465-B781-28ADA0077683@microsoft.com...
    > >I currently have a code which I have listed below which will save a file when
    > > the user selects the button. I have some users who will need to save two or
    > > more files, which directs them to overwrite the file since currently, there
    > > is no identifier in the file name. The indentifier that I would like to add
    > > is on another spreadsheet in the same workbook. (Worksheet name:
    > > Intro--Start Here; cell: G13)
    > >
    > > Does anyone know how I can add this information to the filename so that each
    > > file saved will have a unique name? Thanks for any suggestions.
    > >
    > >
    > > Dim strPath As String
    > > Dim strFileName As String
    > >
    > > strPath = Application.DefaultFilePath & "\"
    > > strFileName = "xxx"
    > >
    > > ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    > > xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    > > , CreateBackup:=False
    > > ActiveWindow.Close
    > > Sheets("Intro--Start Here").Select
    > > MsgBox ("xxx")
    > >
    > > End Sub

    >
    >
    >


  4. #4
    Kevin Lehrbass
    Guest

    RE: Macro Save File (Unique file name)

    Hi SJC,

    Change strFileName = "xxx" to strFileName =
    Range("G13").Value
    Add this Sheets("Intro--Start Here").Select before
    the line above.

    This should do the trick! It basically select your intro sheet, and then
    assigns a cell value (G13 in this case) to a variable which you then use save
    the file.

    Let me know if you have any more questions!

    Cheers,

    Kevin Lehrbass
    kevin@spreadsheetsolutions4u.com
    www.spreadsheetsolutions4u.com



    --
    Kevin Lehrbass
    kevin@spreadsheetsolutions4u.com
    www.spreadsheetsolutions4u.com


    "SJC" wrote:

    > I currently have a code which I have listed below which will save a file when
    > the user selects the button. I have some users who will need to save two or
    > more files, which directs them to overwrite the file since currently, there
    > is no identifier in the file name. The indentifier that I would like to add
    > is on another spreadsheet in the same workbook. (Worksheet name:
    > Intro--Start Here; cell: G13)
    >
    > Does anyone know how I can add this information to the filename so that each
    > file saved will have a unique name? Thanks for any suggestions.
    >
    >
    > Dim strPath As String
    > Dim strFileName As String
    >
    > strPath = Application.DefaultFilePath & "\"
    > strFileName = "xxx"
    >
    > ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    > xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    > , CreateBackup:=False
    > ActiveWindow.Close
    > Sheets("Intro--Start Here").Select
    > MsgBox ("xxx")
    >
    > End Sub


  5. #5
    SJC
    Guest

    RE: Macro Save File (Unique file name)

    That worked great, Kevin. Thanks for all of your help!!

    "Kevin Lehrbass" wrote:

    > Hi SJC,
    >
    > Change strFileName = "xxx" to strFileName =
    > Range("G13").Value
    > Add this Sheets("Intro--Start Here").Select before
    > the line above.
    >
    > This should do the trick! It basically select your intro sheet, and then
    > assigns a cell value (G13 in this case) to a variable which you then use save
    > the file.
    >
    > Let me know if you have any more questions!
    >
    > Cheers,
    >
    > Kevin Lehrbass
    > kevin@spreadsheetsolutions4u.com
    > www.spreadsheetsolutions4u.com
    >
    >
    >
    > --
    > Kevin Lehrbass
    > kevin@spreadsheetsolutions4u.com
    > www.spreadsheetsolutions4u.com
    >
    >
    > "SJC" wrote:
    >
    > > I currently have a code which I have listed below which will save a file when
    > > the user selects the button. I have some users who will need to save two or
    > > more files, which directs them to overwrite the file since currently, there
    > > is no identifier in the file name. The indentifier that I would like to add
    > > is on another spreadsheet in the same workbook. (Worksheet name:
    > > Intro--Start Here; cell: G13)
    > >
    > > Does anyone know how I can add this information to the filename so that each
    > > file saved will have a unique name? Thanks for any suggestions.
    > >
    > >
    > > Dim strPath As String
    > > Dim strFileName As String
    > >
    > > strPath = Application.DefaultFilePath & "\"
    > > strFileName = "xxx"
    > >
    > > ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    > > xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    > > , CreateBackup:=False
    > > ActiveWindow.Close
    > > Sheets("Intro--Start Here").Select
    > > MsgBox ("xxx")
    > >
    > > End Sub


  6. #6
    SJC
    Guest

    RE: Macro Save File (Unique file name)

    I have one more question if you have the time. I am also thinking I would
    like to include 2 cells into the file name, but I am thinking I am not doing
    it right. How would you suggest changing this path? The cell I want to add
    is F@.

    Range("C2").Select
    strPath = Application.DefaultFilePath & "\"
    strFileName = Range("C2").Value & "_xxx"


    "Kevin Lehrbass" wrote:

    > Hi SJC,
    >
    > Change strFileName = "xxx" to strFileName =
    > Range("G13").Value
    > Add this Sheets("Intro--Start Here").Select before
    > the line above.
    >
    > This should do the trick! It basically select your intro sheet, and then
    > assigns a cell value (G13 in this case) to a variable which you then use save
    > the file.
    >
    > Let me know if you have any more questions!
    >
    > Cheers,
    >
    > Kevin Lehrbass
    > kevin@spreadsheetsolutions4u.com
    > www.spreadsheetsolutions4u.com
    >
    >
    >
    > --
    > Kevin Lehrbass
    > kevin@spreadsheetsolutions4u.com
    > www.spreadsheetsolutions4u.com
    >
    >
    > "SJC" wrote:
    >
    > > I currently have a code which I have listed below which will save a file when
    > > the user selects the button. I have some users who will need to save two or
    > > more files, which directs them to overwrite the file since currently, there
    > > is no identifier in the file name. The indentifier that I would like to add
    > > is on another spreadsheet in the same workbook. (Worksheet name:
    > > Intro--Start Here; cell: G13)
    > >
    > > Does anyone know how I can add this information to the filename so that each
    > > file saved will have a unique name? Thanks for any suggestions.
    > >
    > >
    > > Dim strPath As String
    > > Dim strFileName As String
    > >
    > > strPath = Application.DefaultFilePath & "\"
    > > strFileName = "xxx"
    > >
    > > ActiveWorkbook.SaveAs strPath & strFileName, FileFormat:= _
    > > xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    > > , CreateBackup:=False
    > > ActiveWindow.Close
    > > Sheets("Intro--Start Here").Select
    > > MsgBox ("xxx")
    > >
    > > End Sub


+ 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