+ Reply to Thread
Results 1 to 3 of 3

Set Path for GetSaveAsFilename

  1. #1
    JR_06062005
    Guest

    Set Path for GetSaveAsFilename

    Is there a way to set the path for Application.GetSaveAsFilename. The
    dialogue opens at "My Documents". I would like for it to open at a folder on
    a server (not designated as a drive since different users may have the
    address mapped differently)

  2. #2
    Dave Peterson
    Guest

    Re: Set Path for GetSaveAsFilename

    You can use a windows api function that changes the drive. In fact, this works
    with mapped drives, too:

    Option Explicit
    Private Declare Function SetCurrentDirectoryA Lib _
    "kernel32" (ByVal lpPathName As String) As Long
    Sub ChDirNet(szPath As String)
    Dim lReturn As Long
    lReturn = SetCurrentDirectoryA(szPath)
    If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
    End Sub
    Sub testme01()

    Dim myFileName As Variant
    Dim myCurFolder As String
    Dim myNewFolder As String

    myCurFolder = CurDir
    myNewFolder = "\\share\folder1\folder2"

    On Error Resume Next
    ChDirNet myNewFolder
    If Err.Number <> 0 Then
    'what should happen
    MsgBox "Please change to your own folder"
    Err.Clear
    End If
    On Error GoTo 0

    myFileName = Application.GetSaveAsFilename(filefilter:="Excel Files, *.xls")

    ChDirNet myCurFolder

    If myFileName = False Then
    Exit Sub 'user hit cancel
    End If

    'do your stuff...
    End Sub


    JR_06062005 wrote:
    >
    > Is there a way to set the path for Application.GetSaveAsFilename. The
    > dialogue opens at "My Documents". I would like for it to open at a folder on
    > a server (not designated as a drive since different users may have the
    > address mapped differently)


    --

    Dave Peterson

  3. #3
    Ron de Bruin
    Guest

    Re: Set Path for GetSaveAsFilename

    See example 6

    http://www.rondebruin.nl/copy3.htm#select

    I use ChDirNet there


    --
    Regards Ron De Bruin
    http://www.rondebruin.nl



    "JR_06062005" <[email protected]> wrote in message news:[email protected]...
    > Is there a way to set the path for Application.GetSaveAsFilename. The
    > dialogue opens at "My Documents". I would like for it to open at a folder on
    > a server (not designated as a drive since different users may have the
    > address mapped differently)




+ 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