Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open all files in directory | Excel Discussion (Misc queries) | |||
How do you set Excel 2007 to open files in a specific folder? | Excel Discussion (Misc queries) | |||
Open files in the same directory | Excel Discussion (Misc queries) | |||
Macro - Open all word files in a directory | Excel Worksheet Functions | |||
Open all files in a directory | Excel Programming |