View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don M. Don M. is offline
external usenet poster
 
Posts: 51
Default Getting Application.GetOpenFilename to open correct folder

JP, I tried the ChDir line and the folder that opens up is still my Personal
folder in Documents and Settings.

I sure thought that would do the trick. This is what I'm trying to use:

ChDir "\\fileserver\Data\Global\TaskorderDocuments\0 00\" & Region1BulkPrefix
& "\" & Region1BulkID & "\"

OldBulkReportFileName = Application.GetOpenFilename("Microsoft Office
Excel Files(*.xls), *.xls", , "Choose File To Open")

I tried using a local folder, "C:\Windows" and it works fine. But, when I
put in my network folder it won't work. In fact, when I try to open the
network folder, the folder that actually opens up is the "C:\Windows" folder
that opened before, so somewhere that path is being saved as a default.

Don

"JP" wrote:

Don,

If you want the GetOpenFileName Method to start in a specific folder,
use the ChDir Function to change to that folder first.

Dim strFileN As String
ChDir "C:\My Folder\"
strFileN = Application.GetOpenFilename("Microsoft Office Excel Files
(*.xls), *.xls", , "Choose File To Open")

The dialog box will use C:\My Folder\ as the base folder.

HTH,
JP

On Oct 23, 9:52 am, Don M. wrote:
I'm trying to write code that checks to see if a file of a specific name
exists in a folder. If it does then I just continue with my macro. If the
file is not there or is not named correctly I need the macro to open that
folder so I can rename it.

RyanH helped me a bunch yesterday getting code written that will look in the
folder and check for me, but I'm having trouble getting the
Application.GetOpenFilename line to open the correct folder to open. I dont
want the user to have to browse for the folder when the macro already knows
what folder the file is in. It seems to be using some kind of default path
that I can't figure out how to control. This morning it opened the Personal
folder when I tried it after a fresh reboot.

- snip -