+ Reply to Thread
Results 1 to 6 of 6

Prompt where to save the file

  1. #1
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    347

    Prompt where to save the file

    Hello

    I am using the below code (open sourced though) to save a file. File is being saved in the directory same as the directory of the workbook. Is there anyway to make it prompt where to save the file.

    Please Login or Register  to view this content.
    Last edited by Ravana; 03-17-2015 at 06:40 AM.

  2. #2
    Forum Contributor
    Join Date
    06-11-2014
    MS-Off Ver
    Office 2003, 2007 & 2010
    Posts
    119

    Re: Prompt where to save the file

    Hey, the below code should work, just call it as a function in your code:

    Code was originally posted here:
    http://www.mrexcel.com/forum/excel-q...lications.html


    NewName = InputBox("Please Specify the name of your new workbook", "New Copy")
    varPath = GetFolder("C:\")
    if Right(varPath,1) <> "\" Then
    varPath = varPath & "\"
    End If
    ' Save it with the NewName and in the same directory as original
    ActiveWorkbook.SaveCopyAs varPath & NewName & ".xlsx", FileFormat:=51
    ActiveWorkbook.Close
    ActiveWorkbook.Close SaveChanges:=False



    Function GetFolder(strPath As String) As String
    Dim fldr As FileDialog
    Dim sItem As String
    Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
    End With
    NextCode:
    GetFolder = sItem
    Set fldr = Nothing
    End Function

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Prompt where to save the file

    Something like
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    347

    Re: Prompt where to save the file

    @jindon

    Ur code does prompt for directory to save but file is not being saved. No new file is being created.

    @AranDG

    I get "Varibale not Defined" error message (Highlighting "Varpath" in yellow.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Prompt where to save the file

    I thought you knew the rest, did I expect too much?

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    09-16-2014
    Location
    Hyderabad
    MS-Off Ver
    MS Office 2021
    Posts
    347

    Re: Prompt where to save the file

    @Jindon

    I am newbie to VB and still learning things. Thanks for the help.

+ 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. File Name Prompt For Save As
    By Maxal in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-02-2015, 02:54 AM
  2. File Save w/email prompt
    By Merlin54k in forum Excel General
    Replies: 12
    Last Post: 12-12-2006, 05:43 PM
  3. Replies: 1
    Last Post: 02-24-2006, 10:15 PM
  4. [SOLVED] Prompt for Save when closing a file
    By J. Kerr in forum Excel General
    Replies: 0
    Last Post: 10-05-2005, 05:05 PM
  5. Save file -prompt
    By Scott in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2005, 02:06 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