+ Reply to Thread
Results 1 to 5 of 5

Prompt user for a filename

  1. #1
    J S
    Guest

    Prompt user for a filename

    I want to create an excel macro that display the saveas dialog box to the
    user, how do I do that?

    i.e. I want the user to save the current document, but when I use
    thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
    dialog box where the user can select the filename and directory he wants to
    save to.

    -J



  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481

    Prompt user for a filename

    Use

    fileSaveName = Application.GetSaveAsFilename

    see VBA help for complete syntax of filters, etc...

  3. #3
    Edwin Tam
    Guest

    RE: Prompt user for a filename

    You can use the GetSaveAsFilename method. An example is shown below. For more
    information, you can search for the topic "GetSaveAsFilename method" in the
    VBA online help.

    Sub obtain_filename()
    Dim fileSaveName As String
    fileSaveName = Application.GetSaveAsFilename( _
    InitialFileName:="MyFile", FileFilter:="Text Files (*.txt), *.txt")
    If fileSaveName <> False Then
    MsgBox "Save as " & fileSaveName
    End If
    End Sub

    Regards,
    Edwin Tam
    [email protected]
    http://www.vonixx.com





    "J S" wrote:

    > I want to create an excel macro that display the saveas dialog box to the
    > user, how do I do that?
    >
    > i.e. I want the user to save the current document, but when I use
    > thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
    > dialog box where the user can select the filename and directory he wants to
    > save to.
    >
    > -J
    >
    >
    >


  4. #4
    Jim Thomlinson
    Guest

    RE: Prompt user for a filename

    Application.Dialogs(xlDialogSaveAs).Show "C:\Myfile.xls"

    HTH

    "J S" wrote:

    > I want to create an excel macro that display the saveas dialog box to the
    > user, how do I do that?
    >
    > i.e. I want the user to save the current document, but when I use
    > thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
    > dialog box where the user can select the filename and directory he wants to
    > save to.
    >
    > -J
    >
    >
    >


  5. #5
    Hans Petter
    Guest

    Re: Prompt user for a filename

    Use the GetSaveAsFilename method.
    From Excel Helpfile:
    fileSaveName = Application.GetSaveAsFilename( _
    fileFilter:="Text Files (*.txt), *.txt")
    If fileSaveName <> False Then
    MsgBox "Save as " & fileSaveName
    End If

    Then you can use the SaveAs method to save the fileSaveName

    Hans Petter


    "J S" <[email protected]> skrev i melding news:[email protected]...
    > I want to create an excel macro that display the saveas dialog box to the
    > user, how do I do that?
    >
    > i.e. I want the user to save the current document, but when I use
    > thisworkbook.save or thisworkbook.saveas excel does NOT display the saveas
    > dialog box where the user can select the filename and directory he wants

    to
    > save to.
    >
    > -J
    >
    >




+ 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