'4-8-10,lhw
'-add the commonly used dll to the selected project.
' No need to go through the Add Reference screen in VS.
Sub AddGeneralReferences()
Dim proj As EnvDTE.Project
Dim arr As Array = DTE.ActiveSolutionProjects
If Not arr Is Nothing Then
If arr.Length > 0 Then
proj = arr(0)
If Not proj Is Nothing Then
Dim v As VSLangProj.VSProject = proj.Object
Dim r As VSLangProj.References = v.References
If Not r Is Nothing Then
r.Add("System.configuration")
r.Add("System.Drawing")
'not sure why must include the
'full reference to system.web dll.
'Otherwise, COM error will occur.
r.Add("C:\WINDOWS\Microsoft.NET" & _
"\Framework\v2.0.50727\System.Web.dll")
r.Add("System.Web.Services")
End If
End If
End If
End If
End Sub
Showing posts with label VS Macro. Show all posts
Showing posts with label VS Macro. Show all posts
Wednesday, August 4, 2010
Adding DLL reference automatically
It's quite sad when you are trying to add new reference by using the Add Reference provided in the Visual Studio because it is very slow. To speed up the process, you may have to add the following Macro and run it manually. It will add all your Dll references in one click:
Tuesday, June 8, 2010
Macros for Visual Studio
Run Visual Studio.
After that, close the Macros IDE. Now, you may customize the shortcut key to execute the Macro.
- Select Tools \ Macros \ Macros IDE.
- In the Project Explorer (within the Macros IDE), double click MyMacros \ Module1.
- Paste the following codes into the editor.
After that, close the Macros IDE. Now, you may customize the shortcut key to execute the Macro.
- Select Tools \ Customize from VS menu.
- Click Keyboard button (next to the Close button).
- In the "show command containing" field, type "PrintDateTimeSingleLine". This will shortlist the commands that is accessible through VS.
- In the "Press shortcut keys" field, press CTRL+0 and click Assign button.
- Click OK button to save the customized keyboard settings.
- In the coding editor, press CTRL+0 and VS will execute the Macro. So, you don't have to repeatly typing the current date/time for the comments anymore.
Sub PrintDateTime()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert(DateTime.Now.ToString("d.MMM.yyyy, ddd @ hh:mm"))
End If
End Sub
Sub PrintDateTimeSingleLine()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert("//" & DateTime.Now.ToString("d.MMM.yyyy") & "-lhw-")
End If
End Sub
Sub PrintDateTimeProcHeader()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert(DateTime.Now.ToString("d.MMM.yyyy") & "-lhw")
selection.NewLine()
selection.Insert("-")
End If
End Sub
Sub PrintSeparator()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert("//-----------------------------------------------------------------------")
End If
End Sub
Sub PrintHeavySeparator()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert("//=======================================================================")
End If
End Sub
Sub PrintShortSeparator()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert("//-------------------------------------")
End If
End Sub
Sub PrintNotice()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert("//<======")
End If
End Sub
Subscribe to:
Posts (Atom)