Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ChDir statement


Hi,

I am using the "chdir" statement in VBA - in the "before open" private
sub. the statement does not work - the default directory does not
change (stay as "my document").

In the help it is written that The ChDir statement changes the default
directory but not the default drive.

Any ideas ?

Thanks a lot !


--
neta
------------------------------------------------------------------------
neta's Profile: http://www.excelforum.com/member.php...fo&userid=7624
View this thread: http://www.excelforum.com/showthread...hreadid=552335

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default ChDir statement

Use

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

This is not working for a network folder

Use this then

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

Public Sub ChDirNet(szPath As String)
' Rob Bovey
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(szPath)
If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
End Sub


And this in your code

ChDirNet "\\ComputerName\YourFolder"



--
Regards Ron De Bruin
http://www.rondebruin.nl



"neta" wrote in message
...

Hi,

I am using the "chdir" statement in VBA - in the "before open" private
sub. the statement does not work - the default directory does not
change (stay as "my document").

In the help it is written that The ChDir statement changes the default
directory but not the default drive.

Any ideas ?

Thanks a lot !


--
neta
------------------------------------------------------------------------
neta's Profile: http://www.excelforum.com/member.php...fo&userid=7624
View this thread: http://www.excelforum.com/showthread...hreadid=552335



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
My ChDir Statement doesn't work emil Excel Programming 2 May 1st 06 07:57 PM
ChDir - Specify Folder StephanieH Excel Programming 4 December 7th 04 09:45 PM
Problems with ChDrive and ChDir Sophie Excel Programming 5 December 2nd 04 04:33 PM
ChDir Error scain2004[_23_] Excel Programming 1 November 4th 04 08:08 PM
Links and Chdir Hansol Excel Programming 3 April 17th 04 08:52 PM


All times are GMT +1. The time now is 05:11 PM.

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

About Us

"It's about Microsoft Excel"