+ Reply to Thread
Results 1 to 8 of 8

Code for saving file with user decided name.

  1. #1
    Registered User
    Join Date
    02-04-2019
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    15

    Code for saving file with user decided name.

    Hi!
    I want the user to decide the name of the file, but with the code that I have now it saves the excel as "fname".
    Help Thanks!

    Private Sub CommandButton1_Click()
    Dim fname
    fname = InputBox("Enter date and name of file")
    fname = fname & ".xlsm"
    ActiveWorkbook.SaveAs Filename:="C:\Material Inspection\Material Request\fname"
    ThisWorkbook.Close
    End Sub

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Code for saving file with user decided name.

    Maybe:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-04-2019
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    15

    Re: Code for saving file with user decided name.

    It doesn't work

  4. #4
    Registered User
    Join Date
    02-04-2019
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    15

    Re: Code for saving file with user decided name.

    Quote Originally Posted by Kenneth Hobson View Post
    Maybe:
    Please Login or Register  to view this content.
    It doesn't work

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Code for saving file with user decided name.

    Please use Code Tags when posting code according to Forum Rule #2.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Code for saving file with user decided name.

    Doesn't work is a relative term. If you enter an invalid filename, obviously, it won't work. e.g. fname="2/20/2019 Ken.xlsm" is invalid because slash and back-slash characters indicate subfolders.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Code for saving file with user decided name.

    Totally agree with you Kenneth.

    Without any feedback we still don't know what went wrong.

    @ Karro

    Thanks for rep+.

    Maybe you can tell us what made the difference ?
    Last edited by bakerman2; 02-21-2019 at 01:52 AM.

  8. #8
    Registered User
    Join Date
    02-04-2019
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    15

    Re: Code for saving file with user decided name.

    [QUOTE
    Please Login or Register  to view this content.
    [/QUOTE]

    Hello bakerman2 and Kenneth!
    Sorry for late reply.
    It works with the code above. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 06-15-2016, 06:24 PM
  2. [SOLVED] Macro for saving a worksheet to desktop by any user of the file
    By Hardup in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-30-2014, 07:17 AM
  3. Macro for saving a copy of a file with a name provided by the user
    By mike679 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-03-2012, 08:27 AM
  4. Stop a user from saving the file.
    By ChrisMattock in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2007, 05:33 AM
  5. Path for File Saving Defined by USER
    By crapmind in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2007, 09:58 AM
  6. saving the last user who edited the file
    By kman in forum Excel General
    Replies: 1
    Last Post: 02-23-2006, 04:25 AM
  7. [SOLVED] Test User before saving a file.
    By Steven in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2006, 02:15 PM

Tags for this Thread

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