Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set default directory for saving files Vibeke Excel Discussion (Misc queries) 5 August 23rd 07 12:52 PM
MSOffice default directory Max Setting up and Configuration of Excel 0 June 3rd 06 08:39 PM
where is the default directory of excel macros ? excel macros Excel Discussion (Misc queries) 2 January 21st 05 07:16 PM
Setting default pivot table field setting to "sum" Mr. Moose Excel Discussion (Misc queries) 2 December 21st 04 04:43 PM
Set Default Directory bw Excel Programming 4 July 30th 03 11:45 PM


All times are GMT +1. The time now is 07:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"