|
-
February 5th, 2010, 06:07 AM
#1
Custom Macro which searches and opens a file from project or given directories
If we want to open a file included in a visual studio project we need to open the "Solution explorer" and navigate to that particular file. And if the project has many files included in it and the files are not organized with proper filters/groups then finding the file may take considerable time.This tip consists of a visual studio macro which by taking the file name as input opens any file for you.The macro also searches for given file inside predefined directories.
Before going into details of the script here is some basic intoduction to visual studio macros.
Visual studio macros are Visual Basic programmes intended to automate repetetive/common tasks inside visual studio.Visual studio comes with number of built in macros which can be found in "Macro Explorer" (Tools->Macros->Macro Explorer).You can run any macro in the following ways.
By double clicking on the macro in Macro explorer.
By a keyboard short cut
In the Macros IDE.
Visual studio also provides support for creating our own macros. The Macros IDE is the tool used to accomplish this task.For opening Macro IDE press Alt+ F11.
And here is the VB script for opening a file.
Sub openFile()
Dim foldersToSearchForGivenFile AsString() = {"D:\iDevelop\SDKs\Any SDK\source", "D:\TEST_DIRECTORY"} ' Enter here the directories to search for given file . you can enter any number of directories
Dim fileToOpen AsString = InputBox("Enter the name of the file(with extension) to open", "Open File ", ".cpp")
IfString.IsNullOrEmpty(fileToOpen) Then
Return
EndIf
Hope this tip would be useful to everyone.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|