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 / Visual Studio.NET / IDE / February 2007

Tip: Looking for answers? Try searching our database.

World's simplest macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew Chalk - 02 Feb 2007 03:11 GMT
Short break for a stupid question. In VS2005 I want to write a macro that
writes some static text at the current cusrsor location.

Here is what I have (that doesn't work):

DTE.ActiveDocument.OutputString("Copyright (C) 2000-2007 Joe Bloggs
Software, Inc. All Rights Reserved")

Corrections appreciated.

Thanks!
Peter Macej - 02 Feb 2007 09:18 GMT
It should look like:
Sub InsertText()
        DTE.UndoContext.Open("Insert Text")
        Try
            Dim txt As TextSelection
            txt = DTE.ActiveDocument.Selection

            txt.Insert("Copyright (C) 2000-2007 Joe Bloggs Software,
Inc. All Rights Reserved", _
                vsInsertFlags.vsInsertFlagsInsertAtEnd)
            txt.SmartFormat()
        Catch ex As System.Exception
        End Try
        DTE.UndoContext.Close()
    End Sub

I haven't tested it but it should work. I just modified my macro from
http://www.helixoft.com/blog/archives/14

Signature

Peter Macej
Helixoft - http://www.helixoft.com
VSdocman - Commenter and generator of class documentation for C#, VB
.NET and ASP .NET code

Andrew Chalk - 05 Feb 2007 00:55 GMT
Thanks!

That worked and I have bookmarked your site as well.

- A
> It should look like:
> Sub InsertText()
[quoted text clipped - 14 lines]
> I haven't tested it but it should work. I just modified my macro from
> http://www.helixoft.com/blog/archives/14

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.