Results 1 to 7 of 7

Thread: Prompting user for filename in Excel ...

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Question Prompting user for filename in Excel ...

    Hi.

    I have the following code to prompt a user to save an Excel spreadsheet (when I have finished building it !) :

    VB Code:
    1. Do
    2.         fname = Application.GetSaveAsFilename
    3.     Loop Until fname <> ""

    What I need is someone to tell me how I change the default path of the SaveAs box, as it is defaulting to the 'My Documents' folder, and I need 'S:MARGIN'.

    Looking under the various properties for 'APPLICATION', but haven't found what I need yet !

    Thanks.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    You could insert your own commondialog control & use the initial path property of that as a fallback plan...

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Yeah, thats not a bad idea. Cheers Alex.

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    I just tried this myself using win2000 & Excel2000 :
    Code:
    Private Sub CommandButton1_Click()
        Application.GetSaveAsFilename ("S:\Margin")
    End Sub
    and this works. The first argument is the initial filename - so I tried it with S:\Margin\NameOfFile.xls, but playing around & not putting in a filename as above works for me !

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Thats great.

    I'm using Win 98 but it works with that too.

    The only downside is that it doesn't seem to like you specifying subdirectories ! It ignores them and defines the filename as the subdirectory name instead !?!?!

    Thanks for your help.

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    um, nope again
    I can specify them okay -
    1) do you finish it with a "\" symbol ?
    2)( What happens if ou put in a filename after the subfolder
    - i.e. "S:\margin\subfolder\buggerit.xls"

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    No I wasn't putting a '\' on the end of the path name.

    Now I am and its working fine.

    Thanks again for helping me out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width