Opening at current file's path
I have needed many times to open the file dialog at the current file's path so that I can select other files related to current file. For example, we will often be doing 'Find in Files' in MSDEV's Samples Directories or MFC Source Directories. Once some of those files are opened, we would also like to open the related H files or other View files etc. To do that, mostly we open the directory and files explicitly by file dialog. And we can face similar scenario in many other cases.
Instead of opening explicitly, the following simple macro helps to change the DevStudio's current directory to the active file's path and opens the file dialog. Maybe somebody has done this sort of thing before but I thought I could share this with others here.
Sub OpenAtActiveFilePath() 'DESCRIPTION: Sets the application's working directory to the active file's directory Dim PathString PathString = ActiveDocument.Path PrintToOutputWindow "Before: " + Application.CurrentDirectory Application.CurrentDirectory = PathString ExecuteCommand "FileOpen" PrintToOutputWindow "After: " + Application.CurrentDirectory End Sub
Date Last Updated: February 3, 1999

Comments
There are no comments yet. Be the first to comment!