Hi John,
You can do it with mapped drives, but I don't think it's possible without
API calls when you're using UNC paths. With a mapped drive:
ChDrive "U"
ChDir "U:\groups\subdir"
If you must use UNC paths, then this API-based code (posted originally by
Rob Bovey I think) should do the trick:
Private Declare Function SetCurrentDirectoryA Lib _
"kernel32" (ByVal lpPathName As String) As Long
Sub SetUNCPath(szPath As String)
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(szPath)
If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting
path."
End Sub
Sub ChDirUNC_OpenDialog()
On Error GoTo ErrHandler
SetUNCPath "\\LOGD0FILES\OGILVTW\Docs\Temp"
fname = Application.GetOpenFilename(FileFilter:="CSV Files
(*.csv),*.csv")
'Now open the file or what ever
Exit Sub
ErrHandler:
MsgBox "Couldn't set path"
End Sub
--
Regards,
Jake Marx
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]
John Rawlins wrote:
In VBA, I want to use the FindFile or GetOpenFileName
methods. I have a specific directory on a server (eg
\\server\groups\subdir\) that I want to show up in the
open dialog box. But both methods start out in the
directory I last opened from. The CHDIR command had no
effect. Any suggestions would be appreciated.