Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting default directory prior to GetOpenFilename
When using GetOpenFilename the panel displays files in a
particular directory, but I want it to open displaying the files in a sub-directory of that one. I have tried using ChDir to set the default, but it doesn't work (probably because my directory paths are all in UNC form). How can I change the default directory prior to calling GetOpenFilename? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting default directory prior to GetOpenFilename
On Tue, 2 Sep 2003 02:17:11 -0700, "David R"
wrote: When using GetOpenFilename the panel displays files in a particular directory, but I want it to open displaying the files in a sub-directory of that one. I have tried using ChDir to set the default, but it doesn't work (probably because my directory paths are all in UNC form). How can I change the default directory prior to calling GetOpenFilename? I can't say that I've had that kind of problem with ChDir myself. Have you tried this syntax: chdir curdir & "/SubfolderName" That may help to resolve the problem, since it'll use whatever the current PC sees as the current path, regardless of the UNC path. Usually the only "Gotcha" with ChDir is that it won't work if the directory that you want to set as the current one is on a different DRIVE to the current one. In that case you need to use a ChDrive command first. However if the parent folder is opening when you use the GetOpenFileName method, that's unlikely to be the problem here. --------------------------------------------------------- Hank Scorpio scorpionet who hates spam is at iprimus.com.au (You know what to do.) * Please keep all replies in this Newsgroup. Thanks! * |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting default directory prior to GetOpenFilename
Your right, chdir doesn't work with a UNC path. Here is some code
previously posted by Rob Bovey: Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Sub ChDirNet(szPath As String) Dim lReturn As Long lReturn = SetCurrentDirectoryA(szPath) Debug.Print lReturn If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path." End Sub ' usage example Sub FindFile() ChDirNet "\\LOGD0FILES\OGILVTW\Docs\Temp" fName = Application.GetOpenFileName() if fName < False then msgbox fName End if End Sub the declaration must go at the top of a general module. -- Regards, Tom Ogilvy "David R" wrote in message ... When using GetOpenFilename the panel displays files in a particular directory, but I want it to open displaying the files in a sub-directory of that one. I have tried using ChDir to set the default, but it doesn't work (probably because my directory paths are all in UNC form). How can I change the default directory prior to calling GetOpenFilename? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
set default directory for saving files | Excel Discussion (Misc queries) | |||
MSOffice default directory | Setting up and Configuration of Excel | |||
where is the default directory of excel macros ? | Excel Discussion (Misc queries) | |||
Setting default pivot table field setting to "sum" | Excel Discussion (Misc queries) | |||
Set Default Directory | Excel Programming |