devxlogo

Subclassing ChDir

Subclassing ChDir

If your application’s current directory is D:OldDir, the callChDir(C:NewDir) will change the C Drive’s default directory toNewDir, but the application’s current directory will remain D:OldDir.It seemed to me that ChDir should change the application’s currentdirectory in all cases. This subclassed ChDir subroutine handlesdrive changes, too:

 Sub ChDir(Path As String)        Dim TargetDrive As String        ' if 2nd and 3rd letters of target         ' are ":"        If Mid(Path, 2, 2) = ":" Then                TargetDrive = Left(Path, 3)                If TargetDrive <> _                        Left(CurDir, 3) Then                        ChDrive TargetDrive                End If        End If' Call VB's ChDir function        VBA.ChDir PathEnd Sub
See also  11 Effective Keyword Research Tools and Techniques
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist