Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

Macro needed?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim Marsden - 28 Oct 2004 17:40 GMT
Hi

I wish to automatically fill in the assembly attributes (i.e <Assembly:
AssemblyTitle("")> etc) in my assembly.vb files in serveral projects in my
solution. Is there a way of doing this, perhaps with a macro?

Regards
Tim
Gary Chang[MSFT] - 29 Oct 2004 06:58 GMT
Hi Tim,

>Is there a way of doing this, perhaps with a macro?

If you want to play it with a VS.NET IDE Macro, maybe you can take a try on
Edit.Find/Replace function:

Sub SetAssemblyTitle()
    Dim prj As Project
    Dim file As ProjectItem
    Dim AssemblyTitle As String
    For Each prj In DTE.Solution.Projects
         For Each file In prj.ProjectItems
               If file.Name = "AssemblyInfo.vb" Then
                 file.Document.Activate()

                 DTE.ExecuteCommand("Edit.Find")
                 DTE.Windows.Item("AssemblyInfo.vb").Activate()
                 DTE.Find.Action = vsFindAction.vsFindActionReplace
                 DTE.Find.FindWhat = "<Assembly: AssemblyTitle("""")>"

                 Select Case prj.Name
                       Case "Project1"
                             AssemblyTitle = "MyApp1"   'Set your assembly
title here
                       Case "TProject1"
                             AssemblyTitle = "MyApp12"
                       '...
                       '...
                 End Select

                 DTE.Find.ReplaceWith = "<Assembly: AssemblyTitle(""" +
AssemblyTitle + """)>"
                 DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
                 DTE.Find.MatchCase = True
                 DTE.Find.MatchWholeWord = True
                 DTE.Find.Backwards = False
                 DTE.Find.MatchInHiddenText = False
                 DTE.Find.PatternSyntax =
vsFindPatternSyntax.vsFindPatternSyntaxLiteral
                 DTE.Find.Action = vsFindAction.vsFindActionReplace

                 DTE.Find.Execute()
                 DTE.Find.Execute()
                 
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
                 DTE.ActiveDocument.Save()
                 file.Document.Close()   
               End If
         Next
    Next
End Sub

Wish it helps!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Gary Chang[MSFT] - 29 Oct 2004 07:12 GMT
Hi Tim,

By the way, if you just want the project's name as your assembly title, you
can simplify the code as :

'Delete the Select Case code block and modify the following code with
DTE.Find.ReplaceWith = "<Assembly: AssemblyTitle(""" + prj.Name + """)>"

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Tim Marsden - 29 Oct 2004 10:46 GMT
Many Thanks

Just what I was looking for.

Regards
Tim

> Hi Tim,
>
[quoted text clipped - 14 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --------------------
Gary Chang[MSFT] - 30 Oct 2004 03:29 GMT
OK, Tim, I am very glad to know my code works for you!

Good Luck!

Best regards,

Gary Chang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.