+ Reply to Thread
Results 1 to 9 of 9

Template - Save As File Name

  1. #1
    Jani
    Guest

    Template - Save As File Name

    In looking at all these helpful hints, I am doing something wrong with what
    should be simple code. I have an Excel template and want the file to be saved
    to a reference cell. When I click on Save, Close, Save as.. it defaults to
    the name of the template. The associate can save the file wherever she/he
    wants to. Need some assistance - thanks! Jani
    Sub save_it()
    Dim fname
    With ActiveWorkbook
    fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    ..SaveAs fname
    End With
    End Sub

  2. #2
    Dave Peterson
    Guest

    Re: Template - Save As File Name

    Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    run your Save_It macro.



    Jani wrote:
    >
    > In looking at all these helpful hints, I am doing something wrong with what
    > should be simple code. I have an Excel template and want the file to be saved
    > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > the name of the template. The associate can save the file wherever she/he
    > wants to. Need some assistance - thanks! Jani
    > Sub save_it()
    > Dim fname
    > With ActiveWorkbook
    > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > .SaveAs fname
    > End With
    > End Sub


    --

    Dave Peterson

  3. #3
    Jani
    Guest

    Re: Template - Save As File Name

    Wow - thanks for the quick reply!! So it works but not quite right. It saves
    it but on the Desktop since that is where I put it and the associate might
    want to place it elsewhere and the macro needs to run automatically when the
    file is closed. Do you have further instructions for me?

    "Dave Peterson" wrote:

    > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > run your Save_It macro.
    >
    >
    >
    > Jani wrote:
    > >
    > > In looking at all these helpful hints, I am doing something wrong with what
    > > should be simple code. I have an Excel template and want the file to be saved
    > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > the name of the template. The associate can save the file wherever she/he
    > > wants to. Need some assistance - thanks! Jani
    > > Sub save_it()
    > > Dim fname
    > > With ActiveWorkbook
    > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > .SaveAs fname
    > > End With
    > > End Sub

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    Dave Peterson
    Guest

    Re: Template - Save As File Name

    You can specify the location in your code:
    ..SaveAs "C:\myfolder\myfolder\" & fname

    But if you make this automatic when the file is closed, then won't it run each
    time the file is closed? And what happens if the user wants to save to a
    different location--or even close without saving????

    Jani wrote:
    >
    > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > it but on the Desktop since that is where I put it and the associate might
    > want to place it elsewhere and the macro needs to run automatically when the
    > file is closed. Do you have further instructions for me?
    >
    > "Dave Peterson" wrote:
    >
    > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > run your Save_It macro.
    > >
    > >
    > >
    > > Jani wrote:
    > > >
    > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > should be simple code. I have an Excel template and want the file to be saved
    > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > the name of the template. The associate can save the file wherever she/he
    > > > wants to. Need some assistance - thanks! Jani
    > > > Sub save_it()
    > > > Dim fname
    > > > With ActiveWorkbook
    > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > .SaveAs fname
    > > > End With
    > > > End Sub

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

  5. #5
    Jani
    Guest

    Re: Template - Save As File Name

    You are so right. So what would be ideal in my world is if the macro would
    automatically pick up the text in a cell and then the associate would be able
    to browse to where the file should be saved. Is that possible?

    "Dave Peterson" wrote:

    > You can specify the location in your code:
    > ..SaveAs "C:\myfolder\myfolder\" & fname
    >
    > But if you make this automatic when the file is closed, then won't it run each
    > time the file is closed? And what happens if the user wants to save to a
    > different location--or even close without saving????
    >
    > Jani wrote:
    > >
    > > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > > it but on the Desktop since that is where I put it and the associate might
    > > want to place it elsewhere and the macro needs to run automatically when the
    > > file is closed. Do you have further instructions for me?
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > > run your Save_It macro.
    > > >
    > > >
    > > >
    > > > Jani wrote:
    > > > >
    > > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > > should be simple code. I have an Excel template and want the file to be saved
    > > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > > the name of the template. The associate can save the file wherever she/he
    > > > > wants to. Need some assistance - thanks! Jani
    > > > > Sub save_it()
    > > > > Dim fname
    > > > > With ActiveWorkbook
    > > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > > .SaveAs fname
    > > > > End With
    > > > > End Sub
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  6. #6
    Dave Peterson
    Guest

    Re: Template - Save As File Name

    Jim Rech has a BrowseForFolder routine at:
    http://www.oaltd.co.uk/MVP/Default.htm
    (look for BrowseForFolder)

    John Walkenbach has one at:
    http://j-walk.com/ss/excel/tips/tip29.htm

    If you and all your users are running xl2002+, take a look at VBA's help for:
    application.filedialog(msoFileDialogFolderPicker)

    Jani wrote:
    >
    > You are so right. So what would be ideal in my world is if the macro would
    > automatically pick up the text in a cell and then the associate would be able
    > to browse to where the file should be saved. Is that possible?
    >
    > "Dave Peterson" wrote:
    >
    > > You can specify the location in your code:
    > > ..SaveAs "C:\myfolder\myfolder\" & fname
    > >
    > > But if you make this automatic when the file is closed, then won't it run each
    > > time the file is closed? And what happens if the user wants to save to a
    > > different location--or even close without saving????
    > >
    > > Jani wrote:
    > > >
    > > > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > > > it but on the Desktop since that is where I put it and the associate might
    > > > want to place it elsewhere and the macro needs to run automatically when the
    > > > file is closed. Do you have further instructions for me?
    > > >
    > > > "Dave Peterson" wrote:
    > > >
    > > > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > > > run your Save_It macro.
    > > > >
    > > > >
    > > > >
    > > > > Jani wrote:
    > > > > >
    > > > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > > > should be simple code. I have an Excel template and want the file to be saved
    > > > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > > > the name of the template. The associate can save the file wherever she/he
    > > > > > wants to. Need some assistance - thanks! Jani
    > > > > > Sub save_it()
    > > > > > Dim fname
    > > > > > With ActiveWorkbook
    > > > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > > > .SaveAs fname
    > > > > > End With
    > > > > > End Sub
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > > >

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

  7. #7
    Jani
    Guest

    Re: Template - Save As File Name

    Dave - Thanks for your quick responses & excellent help. I will check out the
    two sites you mentioned. jms

    "Dave Peterson" wrote:

    > Jim Rech has a BrowseForFolder routine at:
    > http://www.oaltd.co.uk/MVP/Default.htm
    > (look for BrowseForFolder)
    >
    > John Walkenbach has one at:
    > http://j-walk.com/ss/excel/tips/tip29.htm
    >
    > If you and all your users are running xl2002+, take a look at VBA's help for:
    > application.filedialog(msoFileDialogFolderPicker)
    >
    > Jani wrote:
    > >
    > > You are so right. So what would be ideal in my world is if the macro would
    > > automatically pick up the text in a cell and then the associate would be able
    > > to browse to where the file should be saved. Is that possible?
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > You can specify the location in your code:
    > > > ..SaveAs "C:\myfolder\myfolder\" & fname
    > > >
    > > > But if you make this automatic when the file is closed, then won't it run each
    > > > time the file is closed? And what happens if the user wants to save to a
    > > > different location--or even close without saving????
    > > >
    > > > Jani wrote:
    > > > >
    > > > > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > > > > it but on the Desktop since that is where I put it and the associate might
    > > > > want to place it elsewhere and the macro needs to run automatically when the
    > > > > file is closed. Do you have further instructions for me?
    > > > >
    > > > > "Dave Peterson" wrote:
    > > > >
    > > > > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > > > > run your Save_It macro.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Jani wrote:
    > > > > > >
    > > > > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > > > > should be simple code. I have an Excel template and want the file to be saved
    > > > > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > > > > the name of the template. The associate can save the file wherever she/he
    > > > > > > wants to. Need some assistance - thanks! Jani
    > > > > > > Sub save_it()
    > > > > > > Dim fname
    > > > > > > With ActiveWorkbook
    > > > > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > > > > .SaveAs fname
    > > > > > > End With
    > > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > Dave Peterson
    > > > > >
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  8. #8
    Jani
    Guest

    Re: Template - Save As File Name

    Dave - Thanks for your quick responses & excellent help. I will check out the
    two sites you mentioned. jms

    "Dave Peterson" wrote:

    > Jim Rech has a BrowseForFolder routine at:
    > http://www.oaltd.co.uk/MVP/Default.htm
    > (look for BrowseForFolder)
    >
    > John Walkenbach has one at:
    > http://j-walk.com/ss/excel/tips/tip29.htm
    >
    > If you and all your users are running xl2002+, take a look at VBA's help for:
    > application.filedialog(msoFileDialogFolderPicker)
    >
    > Jani wrote:
    > >
    > > You are so right. So what would be ideal in my world is if the macro would
    > > automatically pick up the text in a cell and then the associate would be able
    > > to browse to where the file should be saved. Is that possible?
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > You can specify the location in your code:
    > > > ..SaveAs "C:\myfolder\myfolder\" & fname
    > > >
    > > > But if you make this automatic when the file is closed, then won't it run each
    > > > time the file is closed? And what happens if the user wants to save to a
    > > > different location--or even close without saving????
    > > >
    > > > Jani wrote:
    > > > >
    > > > > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > > > > it but on the Desktop since that is where I put it and the associate might
    > > > > want to place it elsewhere and the macro needs to run automatically when the
    > > > > file is closed. Do you have further instructions for me?
    > > > >
    > > > > "Dave Peterson" wrote:
    > > > >
    > > > > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > > > > run your Save_It macro.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Jani wrote:
    > > > > > >
    > > > > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > > > > should be simple code. I have an Excel template and want the file to be saved
    > > > > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > > > > the name of the template. The associate can save the file wherever she/he
    > > > > > > wants to. Need some assistance - thanks! Jani
    > > > > > > Sub save_it()
    > > > > > > Dim fname
    > > > > > > With ActiveWorkbook
    > > > > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > > > > .SaveAs fname
    > > > > > > End With
    > > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > Dave Peterson
    > > > > >
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  9. #9
    Jani
    Guest

    Re: Template - Save As File Name

    Dave - Thanks for your quick responses & excellent help. I will check out the
    two sites you mentioned. jms

    "Dave Peterson" wrote:

    > Jim Rech has a BrowseForFolder routine at:
    > http://www.oaltd.co.uk/MVP/Default.htm
    > (look for BrowseForFolder)
    >
    > John Walkenbach has one at:
    > http://j-walk.com/ss/excel/tips/tip29.htm
    >
    > If you and all your users are running xl2002+, take a look at VBA's help for:
    > application.filedialog(msoFileDialogFolderPicker)
    >
    > Jani wrote:
    > >
    > > You are so right. So what would be ideal in my world is if the macro would
    > > automatically pick up the text in a cell and then the associate would be able
    > > to browse to where the file should be saved. Is that possible?
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > You can specify the location in your code:
    > > > ..SaveAs "C:\myfolder\myfolder\" & fname
    > > >
    > > > But if you make this automatic when the file is closed, then won't it run each
    > > > time the file is closed? And what happens if the user wants to save to a
    > > > different location--or even close without saving????
    > > >
    > > > Jani wrote:
    > > > >
    > > > > Wow - thanks for the quick reply!! So it works but not quite right. It saves
    > > > > it but on the Desktop since that is where I put it and the associate might
    > > > > want to place it elsewhere and the macro needs to run automatically when the
    > > > > file is closed. Do you have further instructions for me?
    > > > >
    > > > > "Dave Peterson" wrote:
    > > > >
    > > > > > Instead of using the builtin menus (File|Save, File|SaveAs), have the associate
    > > > > > run your Save_It macro.
    > > > > >
    > > > > >
    > > > > >
    > > > > > Jani wrote:
    > > > > > >
    > > > > > > In looking at all these helpful hints, I am doing something wrong with what
    > > > > > > should be simple code. I have an Excel template and want the file to be saved
    > > > > > > to a reference cell. When I click on Save, Close, Save as.. it defaults to
    > > > > > > the name of the template. The associate can save the file wherever she/he
    > > > > > > wants to. Need some assistance - thanks! Jani
    > > > > > > Sub save_it()
    > > > > > > Dim fname
    > > > > > > With ActiveWorkbook
    > > > > > > fname = .Worksheets("worksheet1").Range("b9").Value & ".xls"
    > > > > > > .SaveAs fname
    > > > > > > End With
    > > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > Dave Peterson
    > > > > >
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


+ 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