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)
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)
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
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)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks