PC Review


Reply
Thread Tools Rate Thread

Chdir does not seem to change the current directory -- ??

 
 
plh
Guest
Posts: n/a
 
      30th Apr 2008
Hello X-L Gurus!
I am using the GetOpenFileName method and I would like to have it open into a
predetermined folder. I wrote the code as follows:

ChDir "G:\MULTUS\PROVEOUT\"
strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
want to process.")

It opens in the "My Documents" folder instead. Any ideas?

Thank You,
-plh

PS:
I also tried
ChDir "G:\MULTUS\PROVEOUT"
strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
want to process.")
That is without the final "\" in the ChDir statement and got the same result.


--
Where are we going and why am I in this HAND BASKET??
 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      30th Apr 2008
Try this instead:

Private Declare Function SetCurrentDirectoryA _
Lib "kernel32" (ByVal lpPathName As String) As
Long

Function ChDirAPI(strFolder As String) As Long
'will return 1 on success and 0 on failure
'will work with a UNC path as well
'-----------------------------------------
ChDirAPI = SetCurrentDirectoryA(strFolder)
End Function

Then just replace your ChDir with ChDirAPI


RBS



"plh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello X-L Gurus!
> I am using the GetOpenFileName method and I would like to have it open
> into a
> predetermined folder. I wrote the code as follows:
>
> ChDir "G:\MULTUS\PROVEOUT\"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file
> you
> want to process.")
>
> It opens in the "My Documents" folder instead. Any ideas?
>
> Thank You,
> -plh
>
> PS:
> I also tried
> ChDir "G:\MULTUS\PROVEOUT"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file
> you
> want to process.")
> That is without the final "\" in the ChDir statement and got the same
> result.
>
>
> --
> Where are we going and why am I in this HAND BASKET??


 
Reply With Quote
 
Dennis
Guest
Posts: n/a
 
      30th Apr 2008
You need to be on drive G: before it will let you change directory

ChDrive "G"
ChDir "G:\MULTUS\PROVEOUT\"

"plh" wrote:

> Hello X-L Gurus!
> I am using the GetOpenFileName method and I would like to have it open into a
> predetermined folder. I wrote the code as follows:
>
> ChDir "G:\MULTUS\PROVEOUT\"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
> want to process.")
>
> It opens in the "My Documents" folder instead. Any ideas?
>
> Thank You,
> -plh
>
> PS:
> I also tried
> ChDir "G:\MULTUS\PROVEOUT"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
> want to process.")
> That is without the final "\" in the ChDir statement and got the same result.
>
>
> --
> Where are we going and why am I in this HAND BASKET??
>

 
Reply With Quote
 
Keith74
Guest
Posts: n/a
 
      30th Apr 2008
Or have a look at the help file on the dialogs object
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      30th Apr 2008
Make sure you change the drive, too:

Dim myFolder as string
myFolder = "G:\MULTUS\PROVEOUT\"
ChDrive myFolder
ChDir myfolder





plh wrote:
>
> Hello X-L Gurus!
> I am using the GetOpenFileName method and I would like to have it open into a
> predetermined folder. I wrote the code as follows:
>
> ChDir "G:\MULTUS\PROVEOUT\"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
> want to process.")
>
> It opens in the "My Documents" folder instead. Any ideas?
>
> Thank You,
> -plh
>
> PS:
> I also tried
> ChDir "G:\MULTUS\PROVEOUT"
> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
> want to process.")
> That is without the final "\" in the ChDir statement and got the same result.
>
> --
> Where are we going and why am I in this HAND BASKET??


--

Dave Peterson
 
Reply With Quote
 
plh
Guest
Posts: n/a
 
      2nd May 2008
Worked Swimmingly, Thank You!
-plh
In article <(E-Mail Removed)>, Dave Peterson says...
>
>Make sure you change the drive, too:
>
>Dim myFolder as string
>myFolder = "G:\MULTUS\PROVEOUT\"
>ChDrive myFolder
>ChDir myfolder
>
>
>
>
>
>plh wrote:
>>
>> Hello X-L Gurus!
>> I am using the GetOpenFileName method and I would like to have it open into a
>> predetermined folder. I wrote the code as follows:
>>
>> ChDir "G:\MULTUS\PROVEOUT\"
>> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
>> want to process.")
>>
>> It opens in the "My Documents" folder instead. Any ideas?
>>
>> Thank You,
>> -plh
>>
>> PS:
>> I also tried
>> ChDir "G:\MULTUS\PROVEOUT"
>> strCurrentFile = Application.GetOpenFilename(, , "Please choose the file you
>> want to process.")
>> That is without the final "\" in the ChDir statement and got the same result.
>>
>> --
>> Where are we going and why am I in this HAND BASKET??

>



--
Where are we going and why am I in this HAND BASKET??
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Current Directory cory.j.layman@gmail.com Microsoft Excel Programming 4 7th Jan 2009 05:58 PM
Change current directory to the directory that the workbook loads from! alondon Microsoft Excel Programming 5 17th Apr 2007 06:05 AM
How to Change the default current directory when entering the cmd window? AN Windows XP General 7 23rd Jan 2007 04:16 PM
How do I create change current directory macro =?Utf-8?B?dGVjaG1hbg==?= Microsoft Word Document Management 1 12th Dec 2005 05:35 PM
changing current directory to that of the current open file unnameable Microsoft Excel Programming 2 19th May 2004 11:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:09 AM.