Article ID: 108351 - Last Review: June 23, 2005 - Revision: 2.0 ChDir May Fail When Changing to a Root DirectoryThis article was previously published under Q108351 On This PageSUMMARY
In Microsoft Excel, the Visual Basic ChDir statement will fail if the path
argument does not contain a backslash character (\). This requirement may
cause problems if you use ChDir to change to a root directory, because the
path of a root directory does not necessarily contain a backslash.
NOTE: When you use Microsoft Excel version 7.0 or later, you won't get an error message, but the directory won't change. For example, the following Visual Basic code will fail
Run-time error '76': Path not found
-or-
Visual Basic Code ExampleMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. This Visual Basic code example displays an input box which asks you which drive or directory you would like to switch to. When you enter a drive or directory, the example checks whether the path you enter contains a backslash and adds one, if needed, before switching to that drive or directory.To run the example, position the insertion point in the line that reads "Sub MainMacro()" and press F5. | Article Translations
|

Back to the top
